π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Use count from search results
Manav Rathi37df79314ad8
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 1f8ee2b27f..e331efb6b1 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -452,12 +452,13 @@ export default function Gallery() {item: (<SearchResultsHeaderselectedOption={selectedSearchOption}+ fileCount={state.searchResults?.length ?? 0}/>),itemType: ITEM_TYPE.HEADER,});}- }, [isInSearchMode, selectedSearchOption]);+ }, [isInSearchMode, selectedSearchOption, state.searchResults]);// TODO: Make this a normal useEffect.useMemoSingleThreaded(async () => {diff --git a/web/packages/new/photos/components/gallery/index.tsx b/web/packages/new/photos/components/gallery/index.tsxindex db1afadf39..17bdbb3073 100644--- a/web/packages/new/photos/components/gallery/index.tsx+++ b/web/packages/new/photos/components/gallery/index.tsx@@ -30,10 +30,12 @@ export type SelectionContext =interface SearchResultsHeaderProps {selectedOption: SearchOption;+ fileCount: number;}export const SearchResultsHeader: React.FC<SearchResultsHeaderProps> = ({selectedOption,+ fileCount,}) => (<GalleryItemsHeaderAdapter><Typography color="text.muted" variant="large">@@ -41,7 +43,7 @@ export const SearchResultsHeader: React.FC<SearchResultsHeaderProps> = ({</Typography><GalleryItemsSummaryname={selectedOption.suggestion.label}- fileCount={selectedOption.fileCount}+ fileCount={fileCount}/></GalleryItemsHeaderAdapter>);diff --git a/web/packages/new/photos/components/gallery/reducer.ts b/web/packages/new/photos/components/gallery/reducer.tsindex 113c945759..ea65269023 100644--- a/web/packages/new/photos/components/gallery/reducer.ts+++ b/web/packages/new/photos/components/gallery/reducer.ts@@ -330,8 +330,8 @@ export type GalleryAction =}| { type: "showPeople" }| { type: "showPerson"; personID: string }- | { type: "setSearchResults"; searchResults: EnteFile[] }| { type: "enterSearchMode"; searchOption: SearchOption | undefined }+ | { type: "setSearchResults"; searchResults: EnteFile[] }| { type: "exitSearch" };const initialGalleryState: GalleryState = {@@ -794,17 +794,17 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (});}- case "setSearchResults":+ case "enterSearchMode":return stateByUpdatingFilteredFiles({...state,- searchResults: action.searchResults,+ isInSearchMode: true,+ selectedSearchOption: action.searchOption,});- case "enterSearchMode":+ case "setSearchResults":return stateByUpdatingFilteredFiles({...state,- isInSearchMode: true,- selectedSearchOption: action.searchOption,+ searchResults: action.searchResults,});case "exitSearch":diff --git a/web/packages/new/photos/services/search/types.ts b/web/packages/new/photos/services/search/types.tsindex ec05988df5..81a8364b4a 100644--- a/web/packages/new/photos/services/search/types.ts+++ b/web/packages/new/photos/services/search/types.ts@@ -40,6 +40,16 @@ export type SearchSuggestion = { label: string } & (*/export interface SearchOption {suggestion: SearchSuggestion;+ /**+ * The count of files that matched the search option when it was initially+ * computed.+ *+ * Later updates (e.g. deletion of files that are being shown as search+ * results) may make this diverge from the correct count, so the gallery+ * should instead take the count from the count of the computed search+ * results. This property is thus meant only for the search dropdown to the+ * show the count.+ */fileCount: number;previewFiles: EnteFile[];}