Skip to content

armgit / ente

Public Imported from GitHub
0

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

Extract

Manav Rathi90c15774d7d2
diff --git a/web/apps/photos/src/pages/gallery/index.tsx b/web/apps/photos/src/pages/gallery/index.tsx
index a5c180c3aa..8bac954cbb 100644
--- a/web/apps/photos/src/pages/gallery/index.tsx
+++ b/web/apps/photos/src/pages/gallery/index.tsx
@@ -1,6 +1,5 @@
import { WhatsNew } from "@/new/photos/components/WhatsNew";
import { shouldShowWhatsNew } from "@/new/photos/services/changelog";
-import { fetchAndSaveFeatureFlagsIfNeeded } from "@/new/photos/services/feature-flags";
import {
getLocalFiles,
getLocalTrashedFiles,
@@ -94,13 +93,12 @@ import {
getSectionSummaries,
} from "services/collectionService";
import downloadManager from "services/download";
-import { syncCLIPEmbeddings } from "services/embeddingService";
-import { syncEntities } from "services/entityService";
import { syncFiles } from "services/fileService";
import locationSearchService from "services/locationSearchService";
+import { sync } from "services/sync";
import { syncTrash } from "services/trashService";
import uploadManager from "services/upload/uploadManager";
-import { isTokenValid, syncMapEnabled } from "services/userService";
+import { isTokenValid } from "services/userService";
import { Collection, CollectionSummaries } from "types/collection";
import {
GalleryContextType,
@@ -720,19 +718,7 @@ export default function Gallery() {
await syncFiles("normal", normalCollections, setFiles);
await syncFiles("hidden", hiddenCollections, setHiddenFiles);
await syncTrash(collections, setTrashedFiles);
- await syncEntities();
- await syncMapEnabled();
- fetchAndSaveFeatureFlagsIfNeeded();
- const electron = globalThis.electron;
- if (electron) {
- await syncCLIPEmbeddings();
- // TODO-ML(MR): Disable fetch until we start storing it in the
- // same place as the local ones.
- // if (isFaceIndexingEnabled()) await syncFaceEmbeddings();
- }
- if (clipService.isPlatformSupported()) {
- void clipService.scheduleImageEmbeddingExtraction();
- }
+ await sync();
} catch (e) {
switch (e.message) {
case CustomError.SESSION_EXPIRED:
diff --git a/web/apps/photos/src/services/sync.ts b/web/apps/photos/src/services/sync.ts
new file mode 100644
index 0000000000..19f5812834
--- /dev/null
+++ b/web/apps/photos/src/services/sync.ts
@@ -0,0 +1,30 @@
+import { fetchAndSaveFeatureFlagsIfNeeded } from "@/new/photos/services/feature-flags";
+import { clipService } from "services/clip-service";
+import { syncCLIPEmbeddings } from "services/embeddingService";
+import { syncEntities } from "services/entityService";
+import { syncMapEnabled } from "services/userService";
+
+/**
+ * Perform a soft "refresh" by making various API calls to fetch state from
+ * remote, using it to update our local state, and triggering periodic jobs that
+ * depend on the local state.
+ */
+export const sync = async () => {
+ // TODO: This is called after we've synced the local files DBs with remote.
+ // That code belongs here, but currently that state is persisted in the top
+ // level gallery React component.
+
+ await syncEntities();
+ await syncMapEnabled();
+ fetchAndSaveFeatureFlagsIfNeeded();
+ const electron = globalThis.electron;
+ if (electron) {
+ await syncCLIPEmbeddings();
+ // TODO-ML(MR): Disable fetch until we start storing it in the
+ // same place as the local ones.
+ // if (isFaceIndexingEnabled()) await syncFaceEmbeddings();
+ }
+ if (clipService.isPlatformSupported()) {
+ void clipService.scheduleImageEmbeddingExtraction();
+ }
+};