Skip to content

armgit / ente

Public Imported from GitHub
0

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

New

Manav Rathi5c55e52cc1b6
diff --git a/web/packages/media/file.ts b/web/packages/media/file.ts
index 044efc1ae1..2dde5a7d01 100644
--- a/web/packages/media/file.ts
+++ b/web/packages/media/file.ts
@@ -321,6 +321,7 @@ export type RemoteEnteFile = z.infer<typeof RemoteEnteFile>;
* Zod schema for a response for various "/diff" APIs that return changes since
* a provided timestamp.
*
+ * - "/collections/v2/diff"
* - "/cast/diff"
*
*/
diff --git a/web/packages/new/photos/services/collection.ts b/web/packages/new/photos/services/collection.ts
index bc69d3f060..0f9b6a8e65 100644
--- a/web/packages/new/photos/services/collection.ts
+++ b/web/packages/new/photos/services/collection.ts
@@ -27,6 +27,7 @@ import {
} from "ente-media/collection";
import {
decryptRemoteFile,
+ FileDiffResponse,
type EnteFile,
type RemoteEnteFile,
} from "ente-media/file";
@@ -370,6 +371,31 @@ export const pullCollectionFiles = async (
return didUpdateFiles;
};
+/**
+ * Fetch all files in the given {@link collection} have been created or updated
+ * since {@link sinceTime}.
+ *
+ * Remote only, does not modify local state.
+ *
+ * @param collection The collection whose updates we want to fetch.
+ *
+ * @param sinceTime The timestamp of most recently update for the collection
+ * that we have already pulled. This serves both as a pagination mechanish, and
+ * a way to fetch a delta diff the next time the client needs to pull changes
+ * from remote.
+ */
+const getCollectionDiff = async (collection: Collection, sinceTime: number) => {
+ const res = await fetch(
+ await apiURL("/collections/v2/diff", {
+ collectionID: collection.id.toString(),
+ sinceTime: sinceTime.toString(),
+ }),
+ { headers: await authenticatedRequestHeaders() },
+ );
+ ensureOk(res);
+ return FileDiffResponse.parse(await res.json());
+};
+
export const getFiles = async (
collection: Collection,
sinceTime: number,