π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
async
Manav Rathi2c46be6dedd4
diff --git a/web/apps/photos/src/components/Upload/Uploader.tsx b/web/apps/photos/src/components/Upload/Uploader.tsxindex a622953b3d..752b729a0e 100644--- a/web/apps/photos/src/components/Upload/Uploader.tsx+++ b/web/apps/photos/src/components/Upload/Uploader.tsx@@ -131,12 +131,6 @@ export default function Uploader(props: Props) {const closeUploadProgress = () => setUploadProgressView(false);const showUserNameInputDialog = () => setUserNameInputDialogView(true);- // eslint-disable-next-line @typescript-eslint/no-unused-vars- const setCollectionName = (collectionName: string) => {- isPendingDesktopUpload.current = true;- pendingDesktopUploadCollectionName.current = collectionName;- };-const handleChoiceModalClose = () => {setChoiceModalView(false);uploadRunning.current = false;@@ -186,13 +180,26 @@ export default function Uploader(props: Props) {);}});- /* TODO(MR): This is the connection point, implement- watcher.init(- setElectronFiles,- setCollectionName,- props.syncWithRemote,- );- */++ // eslint-disable-next-line @typescript-eslint/no-unused-vars+ const upload = (collectionName: string, filePaths: string[]) => {+ isPendingDesktopUpload.current = true;+ pendingDesktopUploadCollectionName.current = collectionName;++ // TODO (MR):+ // setElectronFiles(filePaths);+ };++ const requestSyncWithRemote = () => {+ props.syncWithRemote().catch((e) => {+ log.error(+ "Ignoring error when syncing trash changes with remote",+ e,+ );+ });+ };++ watcher.init(upload, requestSyncWithRemote);}}, [publicCollectionGalleryContext.accessedThroughSharedURL,diff --git a/web/apps/photos/src/services/watch.ts b/web/apps/photos/src/services/watch.tsindex 703dd87ad4..339ae699da 100644--- a/web/apps/photos/src/services/watch.ts+++ b/web/apps/photos/src/services/watch.ts@@ -57,11 +57,12 @@ class FolderWatcher {*/private upload: (collectionName: string, filePaths: string[]) => void;/**- * A function to call when we want to sync with the backend.+ * A function to call when we want to sync with the backend. It will+ * initiate the sync but will not await its completion.** This is passed as a param to {@link init}.*/- private syncWithRemote: () => void;+ private requestSyncWithRemote: () => void;/** A helper function that debounces invocations of {@link runNextEvent}. */private debouncedRunNextEvent: () => void;@@ -80,10 +81,10 @@ class FolderWatcher {*/init(upload: (collectionName: string, filePaths: string[]) => void,- syncWithRemote: () => void,+ requestSyncWithRemote: () => void,) {this.upload = upload;- this.syncWithRemote = syncWithRemote;+ this.requestSyncWithRemote = requestSyncWithRemote;this.registerListeners();this.syncWithDisk();}@@ -504,33 +505,30 @@ class FolderWatcher {}private async moveToTrash(syncedFiles: FolderWatch["syncedFiles"]) {- try {- const files = await getLocalFiles();- const toTrashFilesMap = new Map<number, FolderWatchSyncedFile>();- for (const file of syncedFiles) {- toTrashFilesMap.set(file.uploadedFileID, file);- }- const filesToTrash = files.filter((file) => {- if (toTrashFilesMap.has(file.id)) {- const fileToTrash = toTrashFilesMap.get(file.id);- if (fileToTrash.collectionID === file.collectionID) {- return true;- }+ const files = await getLocalFiles();+ const toTrashFilesMap = new Map<number, FolderWatchSyncedFile>();+ for (const file of syncedFiles) {+ toTrashFilesMap.set(file.uploadedFileID, file);+ }+ const filesToTrash = files.filter((file) => {+ if (toTrashFilesMap.has(file.id)) {+ const fileToTrash = toTrashFilesMap.get(file.id);+ if (fileToTrash.collectionID === file.collectionID) {+ return true;}- });- const groupFilesByCollectionId =- groupFilesBasedOnCollectionID(filesToTrash);-- for (const [- collectionID,- filesToTrash,- ] of groupFilesByCollectionId.entries()) {- await removeFromCollection(collectionID, filesToTrash);}- this.syncWithRemote();- } catch (e) {- log.error("error while trashing by IDs", e);+ });+ const groupFilesByCollectionId =+ groupFilesBasedOnCollectionID(filesToTrash);++ for (const [+ collectionID,+ filesToTrash,+ ] of groupFilesByCollectionId.entries()) {+ await removeFromCollection(collectionID, filesToTrash);}++ this.requestSyncWithRemote();}}