π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Update
Manav Rathi3f50771e18ec
diff --git a/web/packages/new/photos/services/collection.ts b/web/packages/new/photos/services/collection.tsindex d748efd0b7..90113e732b 100644--- a/web/packages/new/photos/services/collection.ts+++ b/web/packages/new/photos/services/collection.ts@@ -32,7 +32,13 @@ import {import { batch, splitByPredicate } from "ente-utils/array";import { z } from "zod/v4";import { requestBatchSize, type UpdateMagicMetadataRequest } from "./file";-import { savedCollections } from "./photos-fdb";+import {+ removeCollectionIDLastSyncTime,+ saveCollections,+ saveCollectionsUpdationTime,+ savedCollections,+ savedCollectionsUpdationTime,+} from "./photos-fdb";import { ensureUserKeyPair, getPublicKey } from "./user";const uncategorizedCollectionName = "Uncategorized";@@ -203,6 +209,43 @@ export interface CollectionChange {updationTime: number;}+/**+ * Pull the latest collections from remote.+ *+ * This function uses a delta diff, pulling only changes since the timestamp+ * saved by the last pull.+ *+ * @returns the latest list of collections, reflecting both the state in our+ * local database and on remote.+ */+export const pullCollections = async (): Promise<Collection[]> => {+ const collections = await savedCollections();+ let sinceTime = (await savedCollectionsUpdationTime()) ?? 0;++ const changes = await getCollections(sinceTime);++ if (!changes.length) return collections;++ const collectionsByID = new Map(collections.map((c) => [c.id, c]));+ for (const { id, updationTime, collection } of changes) {+ sinceTime = Math.max(sinceTime, updationTime);+ if (collection) {+ collectionsByID.set(id, collection);+ } else {+ // Collection was deleted on remote.+ await removeCollectionIDLastSyncTime(id);+ collectionsByID.delete(id);+ }+ }++ const updatedCollections = [...collectionsByID.values()];++ await saveCollections(updatedCollections);+ await saveCollectionsUpdationTime(sinceTime);++ return updatedCollections;+};+/*** Fetch all collections that have been added or updated on remote since* {@link sinceTime}, with markers for those that have been deleted.@@ -215,7 +258,7 @@ export interface CollectionChange {* will be at most one entry for a given collection in the result array. See:* [Note: Diff response will have at most one entry for an id]*/-export const getCollections = async (+const getCollections = async (sinceTime: number,): Promise<CollectionChange[]> => {const res = await fetch(diff --git a/web/packages/new/photos/services/collections.ts b/web/packages/new/photos/services/collections.tsdeleted file mode 100644index 95a5aec896..0000000000--- a/web/packages/new/photos/services/collections.ts+++ /dev/null@@ -1,46 +0,0 @@-import { type Collection } from "ente-media/collection";-import { getCollections } from "./collection";-import {- removeCollectionIDLastSyncTime,- saveCollections,- saveCollectionsUpdationTime,- savedCollections,- savedCollectionsUpdationTime,-} from "./photos-fdb";--/**- * Pull the latest collections from remote.- *- * This function uses a delta diff, pulling only changes since the timestamp- * saved by the last pull.- *- * @returns the latest list of collections, reflecting both the state in our- * local database and on remote.- */-export const pullCollections = async (): Promise<Collection[]> => {- const collections = await savedCollections();- let sinceTime = (await savedCollectionsUpdationTime()) ?? 0;-- const changes = await getCollections(sinceTime);-- if (!changes.length) return collections;-- const collectionsByID = new Map(collections.map((c) => [c.id, c]));- for (const { id, updationTime, collection } of changes) {- sinceTime = Math.max(sinceTime, updationTime);- if (collection) {- collectionsByID.set(id, collection);- } else {- // Collection was deleted on remote.- await removeCollectionIDLastSyncTime(id);- collectionsByID.delete(id);- }- }-- const updatedCollections = [...collectionsByID.values()];-- await saveCollections(updatedCollections);- await saveCollectionsUpdationTime(sinceTime);-- return updatedCollections;-};diff --git a/web/packages/new/photos/services/sync.ts b/web/packages/new/photos/services/sync.tsindex 5f6a5f834d..f4d2aeda0e 100644--- a/web/packages/new/photos/services/sync.ts+++ b/web/packages/new/photos/services/sync.ts@@ -5,15 +5,11 @@ import {} from "ente-gallery/services/video";import type { Collection } from "ente-media/collection";import type { EnteFile } from "ente-media/file";-import { pullCollections } from "ente-new/photos/services/collections";-import { pullCollectionFiles } from "ente-new/photos/services/files";-import {- isMLSupported,- mlStatusSync,- mlSync,-} from "ente-new/photos/services/ml";-import { searchDataSync } from "ente-new/photos/services/search";-import { syncSettings } from "ente-new/photos/services/settings";+import { pullCollections } from "./collection";+import { pullCollectionFiles } from "./files";+import { isMLSupported, mlStatusSync, mlSync } from "./ml";+import { searchDataSync } from "./search";+import { syncSettings } from "./settings";import { pullTrash, type TrashItem } from "./trash";/**