Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions apps/web/src/routes/files/files-list-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,13 @@ export interface FilesViewModel {
sessionOptions: FilesSessionOption[];
}

function matchesSearch(file: ListedFileEntry, search: string): boolean {
const normalized = search.trim().toLowerCase();

if (!normalized) {
function matchesSearch(file: ListedFileEntry, normalizedSearch: string): boolean {
if (!normalizedSearch) {
return true;
}

return [file.name, file.path, file.id, file.mimeType ?? ""].some((value) =>
value.toLowerCase().includes(normalized),
value.toLowerCase().includes(normalizedSearch),
);
}

Expand Down Expand Up @@ -104,6 +102,7 @@ export function createFilesViewModel(
? selection.sessionId
: "";
const sessionById = new Map(sessions.map((session) => [session.id, session]));
const normalizedSearch = selection.search.trim().toLowerCase();
const visibleFiles = files
.filter((file) => {
if (selection.sessionKind !== "all" && file.sessionKind !== selection.sessionKind) {
Expand All @@ -122,7 +121,7 @@ export function createFilesViewModel(
}
}

return matchesSearch(file, selection.search);
return matchesSearch(file, normalizedSearch);
})
.map((file) =>
Object.assign({}, file, {
Expand Down
Loading