Skip to content

armgit / ente

Public Imported from GitHub
0

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

Support num qp

Manav Rathi601a1d029bd1
diff --git a/web/apps/cast/src/services/render.ts b/web/apps/cast/src/services/render.ts
index d989946332..cdae41eb57 100644
--- a/web/apps/cast/src/services/render.ts
+++ b/web/apps/cast/src/services/render.ts
@@ -160,10 +160,9 @@ export const getRemoteCastCollectionFiles = async (
const filesByID = new Map<number, RemoteEnteFile>();
let sinceTime = 0;
while (true) {
- const res = await fetch(
- await apiURL("/cast/diff", { sinceTime: sinceTime.toString() }),
- { headers: { "X-Cast-Access-Token": castToken } },
- );
+ const res = await fetch(await apiURL("/cast/diff", { sinceTime }), {
+ headers: { "X-Cast-Access-Token": castToken },
+ });
ensureOk(res);
const { diff, hasMore } = FileDiffResponse.parse(await res.json());
if (!diff.length) break;
diff --git a/web/packages/base/origins.ts b/web/packages/base/origins.ts
index 2a92a8c587..17466dfece 100644
--- a/web/packages/base/origins.ts
+++ b/web/packages/base/origins.ts
@@ -21,17 +21,21 @@ export const apiOrigin = async () =>
*
* @param queryParams An optional object containing query params. This is
* appended to the generated URL after funneling it through
- * {@link URLSearchParams}.
+ * {@link URLSearchParams}. The values can be `strings` or `numbers` (both of
+ * which are converted to `string`s by using `toString`).
*
* @returns path prefixed by {@link apiOrigin}.
*/
export const apiURL = async (
path: string,
- queryParams?: Record<string, string>,
+ queryParams?: Record<string, string | number>,
) => {
let url = (await apiOrigin()) + path;
if (queryParams) {
- const params = new URLSearchParams(queryParams);
+ const stringQP = Object.fromEntries(
+ Object.entries(queryParams).map(([k, v]) => [k, v.toString()]),
+ );
+ const params = new URLSearchParams(stringQP);
url = `${url}?${params.toString()}`;
}
return url;
diff --git a/web/packages/new/photos/services/collection.ts b/web/packages/new/photos/services/collection.ts
index 0f9b6a8e65..c426306b09 100644
--- a/web/packages/new/photos/services/collection.ts
+++ b/web/packages/new/photos/services/collection.ts
@@ -274,10 +274,9 @@ export const pullCollections = async (): Promise<Collection[]> => {
const getCollections = async (
sinceTime: number,
): Promise<CollectionChange[]> => {
- const res = await fetch(
- await apiURL("/collections/v2", { sinceTime: sinceTime.toString() }),
- { headers: await authenticatedRequestHeaders() },
- );
+ const res = await fetch(await apiURL("/collections/v2", { sinceTime }), {
+ headers: await authenticatedRequestHeaders(),
+ });
ensureOk(res);
const { collections } = CollectionsResponse.parse(await res.json());
return Promise.all(
@@ -372,24 +371,21 @@ export const pullCollectionFiles = async (
};
/**
- * Fetch all files in the given {@link collection} have been created or updated
- * since {@link sinceTime}.
+ * Fetch all files in the given 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 collection The ID of 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 getCollectionDiff = async (collectionID: number, sinceTime: number) => {
const res = await fetch(
- await apiURL("/collections/v2/diff", {
- collectionID: collection.id.toString(),
- sinceTime: sinceTime.toString(),
- }),
+ await apiURL("/collections/v2/diff", { collectionID, sinceTime }),
{ headers: await authenticatedRequestHeaders() },
);
ensureOk(res);
diff --git a/web/packages/new/photos/services/trash.ts b/web/packages/new/photos/services/trash.ts
index af880d9b2a..0f01db31cc 100644
--- a/web/packages/new/photos/services/trash.ts
+++ b/web/packages/new/photos/services/trash.ts
@@ -203,10 +203,9 @@ const TrashDiffResponse = z.object({
* pull changes from remote.
*/
const getTrashDiff = async (sinceTime: number) => {
- const res = await fetch(
- await apiURL("/trash/v2/diff", { sinceTime: sinceTime.toString() }),
- { headers: await authenticatedRequestHeaders() },
- );
+ const res = await fetch(await apiURL("/trash/v2/diff", { sinceTime }), {
+ headers: await authenticatedRequestHeaders(),
+ });
ensureOk(res);
return TrashDiffResponse.parse(await res.json());
};