Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Forward people state

Manav Rathi873ac6b6f742
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index ed77cb7c1f..868e8e3a0b 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -460,6 +460,10 @@ export default function Gallery() {
}
}, [router.isReady]);
+ useEffect(() => {
+ dispatch({ type: "setPeopleState", peopleState });
+ }, [peopleState]);
+
useEffect(() => {
if (isInSearchMode && selectedSearchOption) {
setPhotoListHeader({
@@ -763,14 +767,14 @@ export default function Gallery() {
await syncFiles(
"normal",
collections,
- (files) => dispatch({ type: "resetFiles", files }),
+ (files) => dispatch({ type: "setFiles", files }),
(files) => dispatch({ type: "fetchFiles", files }),
);
await syncFiles(
"hidden",
hiddenCollections,
(hiddenFiles) =>
- dispatch({ type: "resetHiddenFiles", hiddenFiles }),
+ dispatch({ type: "setHiddenFiles", hiddenFiles }),
(hiddenFiles) =>
dispatch({ type: "fetchHiddenFiles", hiddenFiles }),
);
diff --git a/web/packages/new/photos/components/gallery/reducer.ts b/web/packages/new/photos/components/gallery/reducer.ts
index 99267cef9a..2e70060429 100644
--- a/web/packages/new/photos/components/gallery/reducer.ts
+++ b/web/packages/new/photos/components/gallery/reducer.ts
@@ -39,7 +39,7 @@ import {
isArchivedFile,
isPinnedCollection,
} from "../../services/magic-metadata";
-import type { Person } from "../../services/ml/people";
+import type { PeopleState, Person } from "../../services/ml/people";
import type { FamilyData } from "../../services/user";
/**
@@ -85,7 +85,7 @@ export interface GalleryState {
*/
familyData: FamilyData | undefined;
- /*--< Primary state: Files and collections >--*/
+ /*--< Primary state: Files, collections, people >--*/
/**
* The user's non-hidden collections.
@@ -113,6 +113,11 @@ export interface GalleryState {
* The list is sorted so that newer files are first.
*/
trashedFiles: EnteFile[];
+ /**
+ * Latest snapshot of people related state, as reported by
+ * {@link usePeopleStateSnapshot}.
+ */
+ peopleState: PeopleState | undefined;
/*--< Derived state >--*/
@@ -250,12 +255,13 @@ export type GalleryAction =
collections: Collection[];
hiddenCollections: Collection[];
}
- | { type: "resetFiles"; files: EnteFile[] }
+ | { type: "setFiles"; files: EnteFile[] }
| { type: "fetchFiles"; files: EnteFile[] }
| { type: "uploadFile"; file: EnteFile }
- | { type: "resetHiddenFiles"; hiddenFiles: EnteFile[] }
+ | { type: "setHiddenFiles"; hiddenFiles: EnteFile[] }
| { type: "fetchHiddenFiles"; hiddenFiles: EnteFile[] }
| { type: "setTrashedFiles"; trashedFiles: EnteFile[] }
+ | { type: "setPeopleState"; peopleState: PeopleState | undefined }
| { type: "markTempDeleted"; files: EnteFile[] }
| { type: "clearTempDeleted" }
| { type: "markTempHidden"; files: EnteFile[] }
@@ -280,6 +286,7 @@ const initialGalleryState: GalleryState = {
files: [],
hiddenFiles: [],
trashedFiles: [],
+ peopleState: undefined,
archivedCollectionIDs: new Set(),
defaultHiddenCollectionIDs: new Set(),
hiddenFileIDs: new Set(),
@@ -415,7 +422,7 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (
),
};
}
- case "resetFiles": {
+ case "setFiles": {
const files = sortFiles(mergeMetadata(action.files));
return {
...state,
@@ -478,7 +485,7 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (
),
};
}
- case "resetHiddenFiles": {
+ case "setHiddenFiles": {
const hiddenFiles = sortFiles(mergeMetadata(action.hiddenFiles));
return {
...state,
@@ -523,6 +530,8 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (
state.archivedCollectionIDs,
),
};
+ case "setPeopleState":
+ return { ...state, peopleState: action.peopleState };
case "markTempDeleted":
return {
...state,