Skip to content

armgit / ente

Public Imported from GitHub
0

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

Inline

Manav Rathibbe6dde4cb47
diff --git a/web/apps/photos/src/components/Upload/Uploader.tsx b/web/apps/photos/src/components/Upload/Uploader.tsx
index 7afad5227a..eeb869faa2 100644
--- a/web/apps/photos/src/components/Upload/Uploader.tsx
+++ b/web/apps/photos/src/components/Upload/Uploader.tsx
@@ -13,13 +13,14 @@ import { GalleryContext } from "pages/gallery";
import { useContext, useEffect, useRef, useState } from "react";
import billingService from "services/billingService";
import { getLatestCollections } from "services/collectionService";
-import { setToUploadCollection } from "services/pending-uploads";
import {
getPublicCollectionUID,
getPublicCollectionUploaderName,
savePublicCollectionUploaderName,
} from "services/publicCollectionService";
-import uploadManager from "services/upload/uploadManager";
+import uploadManager, {
+ setToUploadCollection,
+} from "services/upload/uploadManager";
import watcher from "services/watch";
import { NotificationAttributes } from "types/Notification";
import { Collection } from "types/collection";
@@ -31,7 +32,11 @@ import {
SetLoading,
UploadTypeSelectorIntent,
} from "types/gallery";
-import { ElectronFile, FileWithCollection, type FileWithCollection2 } from "types/upload";
+import {
+ ElectronFile,
+ FileWithCollection,
+ type FileWithCollection2,
+} from "types/upload";
import {
InProgressUpload,
SegregatedFinishedUploads,
diff --git a/web/apps/photos/src/services/pending-uploads.ts b/web/apps/photos/src/services/pending-uploads.ts
deleted file mode 100644
index 3b219f5b0c..0000000000
--- a/web/apps/photos/src/services/pending-uploads.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import { ensureElectron } from "@/next/electron";
-import { Collection } from "types/collection";
-import { ElectronFile, FileWithCollection } from "types/upload";
-
-export const setToUploadCollection = async (collections: Collection[]) => {
- let collectionName: string = null;
- /* collection being one suggest one of two things
- 1. Either the user has upload to a single existing collection
- 2. Created a new single collection to upload to
- may have had multiple folder, but chose to upload
- to one album
- hence saving the collection name when upload collection count is 1
- helps the info of user choosing this options
- and on next upload we can directly start uploading to this collection
- */
- if (collections.length === 1) {
- collectionName = collections[0].name;
- }
- await ensureElectron().setPendingUploadCollection(collectionName);
-};
-
-export const updatePendingUploads = async (files: FileWithCollection[]) => {
- const filePaths = [];
- for (const fileWithCollection of files) {
- if (fileWithCollection.isLivePhoto) {
- filePaths.push(
- (fileWithCollection.livePhotoAssets.image as ElectronFile).path,
- (fileWithCollection.livePhotoAssets.video as ElectronFile).path,
- );
- } else {
- filePaths.push((fileWithCollection.file as ElectronFile).path);
- }
- }
- await ensureElectron().setPendingUploadFiles("files", filePaths);
-};
-
-export const cancelRemainingUploads = async () => {
- const electron = ensureElectron();
- await electron.setPendingUploadCollection(undefined);
- await electron.setPendingUploadFiles("zips", []);
- await electron.setPendingUploadFiles("files", []);
-};
diff --git a/web/apps/photos/src/services/upload/uploadManager.ts b/web/apps/photos/src/services/upload/uploadManager.ts
index f55c0f51f6..04010e72ff 100644
--- a/web/apps/photos/src/services/upload/uploadManager.ts
+++ b/web/apps/photos/src/services/upload/uploadManager.ts
@@ -1,3 +1,4 @@
+import { ensureElectron } from "@/next/electron";
import log from "@/next/log";
import { ComlinkWorker } from "@/next/worker/comlink-worker";
import { getDedicatedCryptoWorker } from "@ente/shared/crypto";
@@ -7,10 +8,6 @@ import { Events, eventBus } from "@ente/shared/events";
import { Remote } from "comlink";
import { UPLOAD_RESULT, UPLOAD_STAGES } from "constants/upload";
import isElectron from "is-electron";
-import {
- cancelRemainingUploads,
- updatePendingUploads,
-} from "services/pending-uploads";
import {
getLocalPublicFiles,
getPublicCollectionUID,
@@ -21,6 +18,7 @@ import { Collection } from "types/collection";
import { EncryptedEnteFile, EnteFile } from "types/file";
import { SetFiles } from "types/gallery";
import {
+ ElectronFile,
FileWithCollection,
ParsedMetadataJSON,
ParsedMetadataJSONMap,
@@ -529,3 +527,42 @@ class UploadManager {
}
export default new UploadManager();
+
+export const setToUploadCollection = async (collections: Collection[]) => {
+ let collectionName: string = null;
+ /* collection being one suggest one of two things
+ 1. Either the user has upload to a single existing collection
+ 2. Created a new single collection to upload to
+ may have had multiple folder, but chose to upload
+ to one album
+ hence saving the collection name when upload collection count is 1
+ helps the info of user choosing this options
+ and on next upload we can directly start uploading to this collection
+ */
+ if (collections.length === 1) {
+ collectionName = collections[0].name;
+ }
+ await ensureElectron().setPendingUploadCollection(collectionName);
+};
+
+export const updatePendingUploads = async (files: FileWithCollection[]) => {
+ const filePaths = [];
+ for (const fileWithCollection of files) {
+ if (fileWithCollection.isLivePhoto) {
+ filePaths.push(
+ (fileWithCollection.livePhotoAssets.image as ElectronFile).path,
+ (fileWithCollection.livePhotoAssets.video as ElectronFile).path,
+ );
+ } else {
+ filePaths.push((fileWithCollection.file as ElectronFile).path);
+ }
+ }
+ await ensureElectron().setPendingUploadFiles("files", filePaths);
+};
+
+export const cancelRemainingUploads = async () => {
+ const electron = ensureElectron();
+ await electron.setPendingUploadCollection(undefined);
+ await electron.setPendingUploadFiles("zips", []);
+ await electron.setPendingUploadFiles("files", []);
+};