From 1521971a5d8b047b3c469a3c6bbaf89dfdf0db0c Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Wed, 18 Sep 2024 11:53:27 +0530 Subject: [PATCH] Place --- .../new/photos/services/search/worker.ts | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/web/packages/new/photos/services/search/worker.ts b/web/packages/new/photos/services/search/worker.ts index 2061014580..de8ae76ca5 100644 --- a/web/packages/new/photos/services/search/worker.ts +++ b/web/packages/new/photos/services/search/worker.ts @@ -28,6 +28,8 @@ import type { SearchSuggestion, } from "./types"; +type SearchableCGroup = Searchable & { name: string }>; + /** * A web worker that runs the search asynchronously so that the main thread * remains responsive. @@ -39,9 +41,7 @@ export class SearchWorker { collections: [], files: [], }; - private searchableCGroups: Searchable< - Omit & { name: string } - >[] = []; + private searchableCGroups: SearchableCGroup[] = []; /** * Fetch any state we might need when the actual search happens. @@ -102,6 +102,7 @@ export class SearchWorker { s, searchString, this.searchableCollectionsAndFiles, + this.searchableCGroups, localizedSearchData, this.locationTags, this.cities, @@ -139,12 +140,14 @@ const suggestionsForString = ( s: string, searchString: string, { collections, files }: SearchableCollectionsAndFiles, + searchableCGroups: SearchableCGroup[], { locale, holidays, labelledFileTypes }: LocalizedSearchData, locationTags: Searchable[], cities: Searchable[], ): SearchSuggestion[] => [ - // <-- caption suggestions will be inserted here by our caller. + // . <-- clip suggestions will be inserted here by our caller. + peopleSuggestions(s, searchableCGroups), fileTypeSuggestions(s, labelledFileTypes), dateSuggestions(s, locale, holidays), locationSuggestions(s, locationTags, cities), @@ -211,6 +214,24 @@ const fileCaptionSuggestion = ( : []; }; +const peopleSuggestions = ( + s: string, + searchableCGroups: SearchableCGroup[], +): SearchSuggestion[] => { + // Suppress the unused warning during WIP + if (process.env.NEXT_PUBLIC_ENTE_WIP_CL) { + console.log({ s, searchableCGroups }); + } + return []; + // searchableCGroups + // .filter(({ lowercasedName }) => lowercasedName.startsWith(s)) + // .map((scgroup) => ({ + // type: "person", + // person: scgroup, + // label: scgroup.name, + // })); +}; + const dateSuggestions = ( s: string, locale: string,