Skip to content

armgit / ente

Public Imported from GitHub
0

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

Move

Manav Rathi6feb3b789799
diff --git a/web/apps/photos/src/services/collectionService.ts b/web/apps/photos/src/services/collectionService.ts
index 336742b0f2..dae58a96ae 100644
--- a/web/apps/photos/src/services/collectionService.ts
+++ b/web/apps/photos/src/services/collectionService.ts
@@ -8,6 +8,7 @@ import {
UpdateMagicMetadataRequest,
VISIBILITY_STATE,
} from "@/new/photos/types/magicMetadata";
+import { batch } from "@/utils/array";
import ComlinkCryptoWorker from "@ente/shared/crypto";
import { CustomError } from "@ente/shared/error";
import HTTPService from "@ente/shared/network/HTTPService";
@@ -62,7 +63,6 @@ import {
isSharedOnlyViaLink,
isValidMoveTarget,
} from "utils/collection";
-import { batch } from "utils/common";
import {
getUniqueFiles,
groupFilesBasedOnCollectionID,
diff --git a/web/apps/photos/src/services/fileService.ts b/web/apps/photos/src/services/fileService.ts
index deb9bda779..37cbb42798 100644
--- a/web/apps/photos/src/services/fileService.ts
+++ b/web/apps/photos/src/services/fileService.ts
@@ -10,6 +10,7 @@ import {
} from "@/new/photos/types/file";
import { BulkUpdateMagicMetadataRequest } from "@/new/photos/types/magicMetadata";
import { mergeMetadata } from "@/new/photos/utils/file";
+import { batch } from "@/utils/array";
import ComlinkCryptoWorker from "@ente/shared/crypto";
import HTTPService from "@ente/shared/network/HTTPService";
import { getToken } from "@ente/shared/storage/localStorage/helpers";
@@ -17,7 +18,6 @@ import { REQUEST_BATCH_SIZE } from "constants/api";
import exportService from "services/export";
import { Collection } from "types/collection";
import { SetFiles } from "types/gallery";
-import { batch } from "utils/common";
import { decryptFile, getLatestVersionFiles, sortFiles } from "utils/file";
import {
getCollectionLastSyncTime,
diff --git a/web/apps/photos/src/utils/common/index.ts b/web/apps/photos/src/utils/common/index.ts
deleted file mode 100644
index 3472c116e9..0000000000
--- a/web/apps/photos/src/utils/common/index.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-export function batch<T>(arr: T[], batchSize: number): T[][] {
- const batches: T[][] = [];
- for (let i = 0; i < arr.length; i += batchSize) {
- batches.push(arr.slice(i, i + batchSize));
- }
- return batches;
-}
diff --git a/web/packages/utils/array.ts b/web/packages/utils/array.ts
index a27a955498..5f72779f83 100644
--- a/web/packages/utils/array.ts
+++ b/web/packages/utils/array.ts
@@ -46,3 +46,16 @@ export const mergeUint8Arrays = (as: Uint8Array[]) => {
as.reduce((n, xs) => (result.set(xs, n), n + xs.length), 0);
return result;
};
+
+/**
+ * Break an array into batches of size {@link chunkSize}.
+ *
+ * @returns An array of the resultant batches.
+ */
+export const batch = <T>(xs: T[], batchSize: number): T[][] => {
+ const batches: T[][] = [];
+ for (let i = 0; i < xs.length; i += batchSize) {
+ batches.push(xs.slice(i, i + batchSize));
+ }
+ return batches;
+};