Skip to content

armgit / ente

Public Imported from GitHub
0

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

nerf ret

Manav Rathi938e7284d7b2
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index b906cb66a5..a6a3cc2ef9 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -523,7 +523,7 @@ const Page: React.FC = () => {
* {@link remoteFilesPull} is independent.
*/
const remoteFilesPull = useCallback(async () => {
- const didUpdateFiles = await pullFiles({
+ await pullFiles({
onSetCollections: (collections) =>
dispatch({ type: "setCollections", collections }),
onSetCollectionFiles: (collectionFiles) =>
@@ -532,10 +532,9 @@ const Page: React.FC = () => {
dispatch({ type: "augmentCollectionFiles", collectionFiles }),
onSetTrashedItems: (trashItems) =>
dispatch({ type: "setTrashItems", trashItems }),
+ onDidUpdateCollectionFiles: () =>
+ exportService.onLocalFilesUpdated(),
});
- if (didUpdateFiles) {
- exportService.onLocalFilesUpdated();
- }
}, []);
const remotePull = useCallback(
diff --git a/web/packages/new/photos/services/pull.ts b/web/packages/new/photos/services/pull.ts
index 5459b7117a..7061791bc5 100644
--- a/web/packages/new/photos/services/pull.ts
+++ b/web/packages/new/photos/services/pull.ts
@@ -67,6 +67,10 @@ interface PullFilesOpts {
* {@link trashItems}.
*/
onSetTrashedItems: (trashItems: TrashItem[]) => void;
+ /**
+ * Called if one or more files were updated during the pull.
+ */
+ onDidUpdateCollectionFiles: () => void;
}
/**
@@ -79,11 +83,12 @@ interface PullFilesOpts {
*
* See also: [Note: Remote pull]
*
+ * It is not robust to have multiple of these executing in parallel, and caller
+ * should have some mechanism to serialize invocations.
+ *
* @param opts various callbacks that are used by gallery to update its local
* state in tandem with the pull. The callbacks are optional since we might not
* have local state to update, as is the case when this is invoked post dedup.
- *
- * @returns `true` if one or more files were updated during the pull.
*/
export const pullFiles = async (opts?: PullFilesOpts) => {
const collections = await pullCollections();
@@ -100,15 +105,15 @@ export const pullFiles = async (opts?: PullFilesOpts) => {
);
if (didUpdateFiles) {
// TODO: Ok for now since its is only commented for the deduper (gallery
- // does this on the return value), but still needs fixing instead of a
- // hidden gotcha. Fix is simple, just uncomment, but that can be done
- // once the exportService can be imported here in the ente-new package.
+ // does this by providing onDidUpdateCollectionFiles), but still needs
+ // fixing instead of a hidden gotcha. Fix is simple, just uncomment, but
+ // that can be done once the exportService can be imported here in the
+ // ente-new package.
//
// exportService.onLocalFilesUpdated();
+ opts?.onDidUpdateCollectionFiles();
resetFileViewerDataSourceOnClose();
- return true;
}
- return false;
};
/**