Skip to content

armgit / ente

Public Imported from GitHub
0

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

Sketch 1

Manav Rathi21738995ccd2
diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsx
index 81cb4fe472..0d2de6617b 100644
--- a/web/apps/photos/src/pages/shared-albums.tsx
+++ b/web/apps/photos/src/pages/shared-albums.tsx
@@ -163,7 +163,7 @@ export default function PublicCollectionGallery() {
}, []);
const onAddPhotos = useMemo(() => {
- return publicCollection?.publicURLs?.[0]?.enableCollect
+ return publicCollection?.publicURLs[0]?.enableCollect
? () => setUploadTypeSelectorView(true)
: undefined;
}, [publicCollection]);
diff --git a/web/packages/new/albums/services/public-collection.ts b/web/packages/new/albums/services/public-collection.ts
index c4aa363ddd..8d776ce4d6 100644
--- a/web/packages/new/albums/services/public-collection.ts
+++ b/web/packages/new/albums/services/public-collection.ts
@@ -2,6 +2,7 @@ import { deriveKey } from "ente-base/crypto";
import {
authenticatedPublicAlbumsRequestHeaders,
ensureOk,
+ type PublicAlbumsCredentials,
} from "ente-base/http";
import { apiURL } from "ente-base/origins";
import {
@@ -10,6 +11,7 @@ import {
type Collection,
type PublicURL,
} from "ente-media/collection";
+import type { EnteFile } from "ente-media/file";
import { z } from "zod/v4";
import {
saveLastPublicCollectionReferralCode,
@@ -129,3 +131,34 @@ const getPublicCollectionInfo = async (accessToken: string) => {
ensureOk(res);
return PublicCollectionInfo.parse(await res.json());
};
+
+/**
+ * Pull any changes to the files belonging to the given collection, updating our
+ * local database and also calling the provided callback.
+ *
+ * This function modifies local state.
+ *
+ * The pull uses a persisted timestamp for the most recent change we've already
+ * fetched, and will be only fetch the delta of changes since the last pull. The
+ * files are fetched in a paginated manner, so the provided callback can get
+ * called multiple times during the pull (one for each page).
+ *
+ * @param credentials A public collection access key and an optional password
+ * unlocked access token JWT. The credentials serve to both identify the
+ * collection, and authenticate the request.
+ *
+ * @param collection The public collection corresponding to the credentials.
+ *
+ * @param onSetFiles A callback that is invoked each time a new batch of updates
+ * to the collection's files is fetched and processed. THe callback is called
+ * the consolidated list of files after applying the updates received so far.
+ *
+ * This callback can get called multiple times during the pull.
+ */
+export const pullPublicCollectionFiles = (
+ credentials: PublicAlbumsCredentials,
+ collection: Collection,
+ onSetFiles: (files: EnteFile[]) => void,
+) => {
+ throw new Error("X");
+};
diff --git a/web/packages/new/photos/services/pull.ts b/web/packages/new/photos/services/pull.ts
index 485b6d9d3a..21e276a6ca 100644
--- a/web/packages/new/photos/services/pull.ts
+++ b/web/packages/new/photos/services/pull.ts
@@ -79,7 +79,8 @@ interface PullFilesOpts {
}
/**
- * Pull the latest collections, collections files and trash items from remote.
+ * Pull the latest collections, collections files and trash items from remote,
+ * updating our local database and also calling the provided callbacks.
*
* This is a subset of a full remote pull, independently exposed for use at
* times when we only want to pull the file related information (e.g. we just