π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
feat(SearchBar):exit-dispatcher-notifier-updated-with-prop-for-conditional-exits
Aswin Asok8917d2f82f3a
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 635b9c303d..2ebb6e4c62 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -776,6 +776,7 @@ const Page: React.FC = () => {const handleSelectSearchOption = (searchOption: SearchOption | undefined,+ options?: { shouldExitSearchMode?: boolean },) => {if (searchOption) {const type = searchOption.suggestion.type;@@ -796,7 +797,9 @@ const Page: React.FC = () => {});}} else {- dispatch({ type: "exitSearch" });+ // Pass shouldExitSearchMode to the reducer (defaults to true for backward compatibility)+ const shouldExitSearchMode = options?.shouldExitSearchMode ?? true;+ dispatch({ type: "exitSearch", shouldExitSearchMode });}};diff --git a/web/packages/new/photos/components/SearchBar.tsx b/web/packages/new/photos/components/SearchBar.tsxindex 284e220436..ae15c2ffe5 100644--- a/web/packages/new/photos/components/SearchBar.tsx+++ b/web/packages/new/photos/components/SearchBar.tsx@@ -74,7 +74,10 @@ export interface SearchBarProps {/*** Set or clear the selected {@link SearchOption}.*/- onSelectSearchOption: (o: SearchOption | undefined) => void;+ onSelectSearchOption: (+ o: SearchOption | undefined,+ options?: { shouldExitSearchMode?: boolean },+ ) => void;/*** Called when the user selects the generic "People" header in the empty* state view.@@ -192,7 +195,10 @@ const SearchInput: React.FC<Omit<SearchBarProps, "onShowSearchInput">> = ({}// Let our parent know the selection was changed.- onSelectSearchOption(nullToUndefined(value));+ // When selecting an option, we should exit search mode if needed.+ onSelectSearchOption(nullToUndefined(value), {+ shouldExitSearchMode: true,+ });// The Select has a blurInputOnSelect prop, but that makes the input// field lose focus, not the entire menu (e.g. when pressing twice).@@ -211,6 +217,10 @@ const SearchInput: React.FC<Omit<SearchBarProps, "onShowSearchInput">> = ({if (value === "") {setValue(null);setInputValue("");+ // Notify parent but don't exit search mode on mobile+ onSelectSearchOption(undefined, {+ shouldExitSearchMode: false,+ });}}};@@ -223,8 +233,8 @@ const SearchInput: React.FC<Omit<SearchBarProps, "onShowSearchInput">> = ({setValue(null);setInputValue("");- // Let our parent know.- onSelectSearchOption(undefined);+ // Let our parent know and exit search mode entirely.+ onSelectSearchOption(undefined, { shouldExitSearchMode: true });};const handleSelectPeople = () => {diff --git a/web/packages/new/photos/components/gallery/reducer.ts b/web/packages/new/photos/components/gallery/reducer.tsindex d7aedfc0cb..1a23bcac85 100644--- a/web/packages/new/photos/components/gallery/reducer.ts+++ b/web/packages/new/photos/components/gallery/reducer.ts@@ -485,7 +485,7 @@ export type GalleryAction =| { type: "enterSearchMode"; searchSuggestion?: SearchSuggestion }| { type: "updatingSearchResults" }| { type: "setSearchResults"; searchResults: EnteFile[] }- | { type: "exitSearch" };+ | { type: "exitSearch"; shouldExitSearchMode?: boolean };const initialGalleryState: GalleryState = {user: undefined,@@ -1139,15 +1139,18 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (isRecomputingSearchResults: false,});- case "exitSearch":+ case "exitSearch": {+ // Only exit search mode if explicitly requested (defaults to true for backward compatibility)+ const shouldExitSearchMode = action.shouldExitSearchMode ?? true;return stateByUpdatingFilteredFiles({...state,searchResults: undefined,searchSuggestion: undefined,isRecomputingSearchResults: false,pendingSearchSuggestions: [],- isInSearchMode: false,+ isInSearchMode: shouldExitSearchMode ? false : state.isInSearchMode,});+ }}};