π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Propagate
Manav Rathi2d8bcd253087
diff --git a/desktop/src/main/ipc.ts b/desktop/src/main/ipc.tsindex bde28d940a..6e8bbe3f71 100644--- a/desktop/src/main/ipc.ts+++ b/desktop/src/main/ipc.ts@@ -52,12 +52,11 @@ import {saveEncryptionKey,} from "./services/store";import {- clearPendingUploads,- getElectronFilesFromGoogleZip,lsZip,pendingUploads,- setPendingUploadCollection,- setPendingUploadFiles,+ setPendingUploads,+ markUploaded,+ clearPendingUploads,} from "./services/upload";import {watchAdd,@@ -204,14 +203,11 @@ export const attachIPCHandlers = () => {ipcMain.handle("pendingUploads", () => pendingUploads());- ipcMain.handle("setPendingUploadCollection", (_, collectionName: string) =>- setPendingUploadCollection(collectionName),- );+ ipcMain.handle("setPendingUploads", (_, pendingUploads: PendingUploads) =>+ setPendingUploads(pendingUploads),- ipcMain.handle(- "setPendingUploadFiles",- (_, type: PendingUploads["type"], filePaths: string[]) =>- setPendingUploadFiles(type, filePaths),+ ipcMain.handle("markUploaded", (_, pathOrZipEntry: string | [zipPath: string, entryName: string]) =>+ markUploaded(pathOrZipEntry),);ipcMain.handle("clearPendingUploads", () => clearPendingUploads());diff --git a/desktop/src/main/services/upload.ts b/desktop/src/main/services/upload.tsindex 1ca7c2bc4e..66c97e34c7 100644--- a/desktop/src/main/services/upload.ts+++ b/desktop/src/main/services/upload.ts@@ -26,7 +26,8 @@ export const lsZip = async (zipPath: string) => {return [entryPaths];};-export const pendingUploads = async () => {+export const pendingUploads = async (): Promise<PendingUploads | undefined> => {+ /* TODO */const collectionName = uploadStatusStore.get("collectionName");const filePaths = validSavedPaths("files");const zipPaths = validSavedPaths("zips");@@ -56,7 +57,14 @@ export const pendingUploads = async () => {};};-export const validSavedPaths = (type: PendingUploads["type"]) => {+export const setPendingUploads = async (pendingUploads: PendingUploads) =>+ uploadStatusStore.set(pendingUploads);++export const markUploaded = async (+ pathOrZipEntry: string | [zipPath: string, entryName: string],+) => {};++const validSavedPaths = (type: PendingUploads["type"]) => {const key = storeKey(type);const savedPaths = (uploadStatusStore.get(key) as string[]) ?? [];const paths = savedPaths.filter((p) => existsSync(p));@@ -64,12 +72,12 @@ export const validSavedPaths = (type: PendingUploads["type"]) => {return paths;};-export const setPendingUploadCollection = (collectionName: string) => {+const setPendingUploadCollection = (collectionName: string) => {if (collectionName) uploadStatusStore.set("collectionName", collectionName);else uploadStatusStore.delete("collectionName");};-export const setPendingUploadFiles = (+const setPendingUploadFiles = (type: PendingUploads["type"],filePaths: string[],) => {@@ -78,9 +86,7 @@ export const setPendingUploadFiles = (else uploadStatusStore.delete(key);};-export const clearPendingUploads = () => {- uploadStatusStore.clear();-};+export const clearPendingUploads = () => uploadStatusStore.clear();const storeKey = (type: PendingUploads["type"]): keyof UploadStatusStore => {switch (type) {diff --git a/desktop/src/main/stores/upload-status.ts b/desktop/src/main/stores/upload-status.tsindex 4a402333a7..36a7d1fa72 100644--- a/desktop/src/main/stores/upload-status.ts+++ b/desktop/src/main/stores/upload-status.ts@@ -10,7 +10,7 @@ export interface UploadStatusStore {*/zipEntries: [zipPath: string, entryName: string][];/** Legacy paths to zip files, now subsumed into zipEntries */- zipPaths: string[];+ zipPaths?: string[];}const uploadStatusSchema: Schema<UploadStatusStore> = {diff --git a/desktop/src/preload.ts b/desktop/src/preload.tsindex ad93a40f6a..c3737aceba 100644--- a/desktop/src/preload.ts+++ b/desktop/src/preload.ts@@ -247,26 +247,16 @@ const lsZip = (zipPath: string): Promise<string[]> =>const pendingUploads = (): Promise<PendingUploads | undefined> =>ipcRenderer.invoke("pendingUploads");-const setPendingUploadCollection = (collectionName: string): Promise<void> =>- ipcRenderer.invoke("setPendingUploadCollection", collectionName);+const setPendingUploads = (pendingUploads: PendingUploads): Promise<void> =>+ ipcRenderer.invoke("setPendingUploads", pendingUploads);-const setPendingUploadFiles = (- type: PendingUploads["type"],- filePaths: string[],-): Promise<void> =>- ipcRenderer.invoke("setPendingUploadFiles", type, filePaths);+const markUploaded = (+ pathOrZipEntry: string | [zipPath: string, entryName: string],+): Promise<void> => ipcRenderer.invoke("markUploaded", pathOrZipEntry);const clearPendingUploads = (): Promise<void> =>ipcRenderer.invoke("clearPendingUploads");-// - TODO: AUDIT below this-// ---const getElectronFilesFromGoogleZip = (- filePath: string,-): Promise<ElectronFile[]> =>- ipcRenderer.invoke("getElectronFilesFromGoogleZip", filePath);-/*** These objects exposed here will become available to the JS code in our* renderer (the web/ code) as `window.ElectronAPIs.*`@@ -378,11 +368,7 @@ contextBridge.exposeInMainWorld("electron", {lsZip,pendingUploads,- setPendingUploadCollection,- setPendingUploadFiles,+ setPendingUploads,+ markUploaded,clearPendingUploads,-- // --- getElectronFilesFromGoogleZip,});diff --git a/desktop/src/types/ipc.ts b/desktop/src/types/ipc.tsindex 3fa375eabf..f343e2bba3 100644--- a/desktop/src/types/ipc.ts+++ b/desktop/src/types/ipc.ts@@ -27,8 +27,8 @@ export interface FolderWatchSyncedFile {export interface PendingUploads {collectionName: string;- type: "files" | "zips";- files: ElectronFile[];+ filePaths: string[];+ zipEntries: [zipPath: string, entryName: string][];}/**