π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Move to reducer
Manav Rathifc5d1f931cef
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 55bc583c6e..1f8ee2b27f 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -258,10 +258,6 @@ export default function Gallery() {const closeAuthenticateUserModal = () =>setAuthenticateUserModalView(false);- // The option selected by the user selected from the search bar dropdown.- const [selectedSearchOption, setSelectedSearchOption] = useState<- SearchOption | undefined- >();// If the fix creation time dialog is being shown, then the list of files on// which it should act.const [fixCreationTimeFiles, setFixCreationTimeFiles] = useState<@@ -313,6 +309,7 @@ export default function Gallery() {state.view?.type == "people" ? state.view.activePerson : undefined;const activePersonID = activePerson?.id;const isInSearchMode = state.isInSearchMode;+ const selectedSearchOption = state.selectedSearchOption;const filteredFiles = state.filteredFiles;if (process.env.NEXT_PUBLIC_ENTE_WIP_CL) console.log("render", state);@@ -783,13 +780,10 @@ export default function Gallery() {personID: searchOption.suggestion.person.id,});}- setSelectedSearchOption(undefined);} else if (searchOption) {- dispatch({ type: "enterSearchMode" });- setSelectedSearchOption(searchOption);+ dispatch({ type: "enterSearchMode", searchOption });} else {dispatch({ type: "exitSearch" });- setSelectedSearchOption(undefined);}setIsClipSearchResult(type == "clip");};@@ -937,7 +931,10 @@ export default function Gallery() {openUploader,isInSearchMode,onShowSearchInput: () =>- dispatch({ type: "enterSearchMode" }),+ dispatch({+ type: "enterSearchMode",+ searchOption: undefined,+ }),onSelectSearchOption: handleSelectSearchOption,onSelectPeople: () =>dispatch({ type: "showPeople" }),diff --git a/web/packages/new/photos/components/gallery/reducer.ts b/web/packages/new/photos/components/gallery/reducer.tsindex b83dff05b5..113c945759 100644--- a/web/packages/new/photos/components/gallery/reducer.ts+++ b/web/packages/new/photos/components/gallery/reducer.ts@@ -39,6 +39,7 @@ import {isPinnedCollection,} from "../../services/magic-metadata";import type { PeopleState, Person } from "../../services/ml/people";+import type { SearchOption } from "../../services/search/types";import type { FamilyData } from "../../services/user-details";/**@@ -244,6 +245,12 @@ export interface GalleryState {* person in the people bar until the user switches to some other view.*/extraVisiblePerson: Person | undefined;+ /**+ * The option selected by the user selected from the search bar dropdown.+ *+ * This is used to compute the {@link searchResults}.+ */+ selectedSearchOption: SearchOption | undefined;/*** List of files that match the selected search option.*@@ -324,7 +331,7 @@ export type GalleryAction =| { type: "showPeople" }| { type: "showPerson"; personID: string }| { type: "setSearchResults"; searchResults: EnteFile[] }- | { type: "enterSearchMode" }+ | { type: "enterSearchMode"; searchOption: SearchOption | undefined }| { type: "exitSearch" };const initialGalleryState: GalleryState = {@@ -349,6 +356,7 @@ const initialGalleryState: GalleryState = {selectedCollectionSummaryID: undefined,selectedPersonID: undefined,extraVisiblePerson: undefined,+ selectedSearchOption: undefined,searchResults: undefined,view: undefined,filteredFiles: [],@@ -681,6 +689,7 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (...state,selectedCollectionSummaryID: undefined,extraVisiblePerson: undefined,+ selectedSearchOption: undefined,searchResults: undefined,view: {type: "albums",@@ -695,6 +704,7 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (...state,selectedCollectionSummaryID: undefined,extraVisiblePerson: undefined,+ selectedSearchOption: undefined,searchResults: undefined,view: {type: "hidden-albums",@@ -715,6 +725,7 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (...state,selectedCollectionSummaryID,extraVisiblePerson: undefined,+ selectedSearchOption: undefined,searchResults: undefined,view,isInSearchMode: false,@@ -727,6 +738,7 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (selectedCollectionSummaryID: action.collectionSummaryID,extraVisiblePerson: undefined,searchResults: undefined,+ selectedSearchOption: undefined,view: {type:action.collectionSummaryID !== undefined &&@@ -757,6 +769,7 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (selectedPersonID: view.activePerson?.id,extraVisiblePerson,searchResults: undefined,+ selectedSearchOption: undefined,view,isInSearchMode: false,});@@ -772,9 +785,10 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = ();return stateByUpdatingFilteredFiles({...state,- searchResults: undefined,selectedPersonID: view.activePerson?.id,extraVisiblePerson,+ searchResults: undefined,+ selectedSearchOption: undefined,view,isInSearchMode: false,});@@ -790,11 +804,14 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (return stateByUpdatingFilteredFiles({...state,isInSearchMode: true,+ selectedSearchOption: action.searchOption,});case "exitSearch":return stateByUpdatingFilteredFiles({...state,+ searchResults: undefined,+ selectedSearchOption: undefined,isInSearchMode: false,});}