Take 2
This commit is contained in:
parent
2d8bcd2530
commit
3b6204f47d
4 changed files with 45 additions and 21 deletions
|
@ -52,11 +52,12 @@ import {
|
|||
saveEncryptionKey,
|
||||
} from "./services/store";
|
||||
import {
|
||||
clearPendingUploads,
|
||||
lsZip,
|
||||
markUploadedFiles,
|
||||
markUploadedZipEntries,
|
||||
pendingUploads,
|
||||
setPendingUploads,
|
||||
markUploaded,
|
||||
clearPendingUploads,
|
||||
} from "./services/upload";
|
||||
import {
|
||||
watchAdd,
|
||||
|
@ -205,18 +206,20 @@ export const attachIPCHandlers = () => {
|
|||
|
||||
ipcMain.handle("setPendingUploads", (_, pendingUploads: PendingUploads) =>
|
||||
setPendingUploads(pendingUploads),
|
||||
);
|
||||
|
||||
ipcMain.handle("markUploaded", (_, pathOrZipEntry: string | [zipPath: string, entryName: string]) =>
|
||||
markUploaded(pathOrZipEntry),
|
||||
ipcMain.handle(
|
||||
"markUploadedFiles",
|
||||
(_, paths: PendingUploads["filePaths"]) => markUploadedFiles(paths),
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
"markUploadedZipEntries",
|
||||
(_, zipEntries: PendingUploads["zipEntries"]) =>
|
||||
markUploadedZipEntries(zipEntries),
|
||||
);
|
||||
|
||||
ipcMain.handle("clearPendingUploads", () => clearPendingUploads());
|
||||
|
||||
// -
|
||||
|
||||
ipcMain.handle("getElectronFilesFromGoogleZip", (_, filePath: string) =>
|
||||
getElectronFilesFromGoogleZip(filePath),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -60,9 +60,21 @@ export const pendingUploads = async (): Promise<PendingUploads | undefined> => {
|
|||
export const setPendingUploads = async (pendingUploads: PendingUploads) =>
|
||||
uploadStatusStore.set(pendingUploads);
|
||||
|
||||
export const markUploaded = async (
|
||||
pathOrZipEntry: string | [zipPath: string, entryName: string],
|
||||
) => {};
|
||||
export const markUploadedFiles = async (paths: string[]) => {
|
||||
const existing = uploadStatusStore.get("filePaths");
|
||||
const updated = existing.filter((p) => !paths.includes(p));
|
||||
uploadStatusStore.set("filePaths", updated);
|
||||
};
|
||||
|
||||
export const markUploadedZipEntries = async (
|
||||
entries: [zipPath: string, entryName: string][],
|
||||
) => {
|
||||
const existing = uploadStatusStore.get("zipEntries");
|
||||
const updated = existing.filter(
|
||||
(z) => !entries.some((e) => z[0] == e[0] && z[1] == e[1]),
|
||||
);
|
||||
uploadStatusStore.set("zipEntries", updated);
|
||||
};
|
||||
|
||||
const validSavedPaths = (type: PendingUploads["type"]) => {
|
||||
const key = storeKey(type);
|
||||
|
|
|
@ -250,9 +250,12 @@ const pendingUploads = (): Promise<PendingUploads | undefined> =>
|
|||
const setPendingUploads = (pendingUploads: PendingUploads): Promise<void> =>
|
||||
ipcRenderer.invoke("setPendingUploads", pendingUploads);
|
||||
|
||||
const markUploaded = (
|
||||
pathOrZipEntry: string | [zipPath: string, entryName: string],
|
||||
): Promise<void> => ipcRenderer.invoke("markUploaded", pathOrZipEntry);
|
||||
const markUploadedFiles = (paths: PendingUploads["filePaths"]): Promise<void> =>
|
||||
ipcRenderer.invoke("markUploadedFiles", paths);
|
||||
|
||||
const markUploadedZipEntries = (
|
||||
zipEntries: PendingUploads["zipEntries"],
|
||||
): Promise<void> => ipcRenderer.invoke("markUploadedZipEntries", zipEntries);
|
||||
|
||||
const clearPendingUploads = (): Promise<void> =>
|
||||
ipcRenderer.invoke("clearPendingUploads");
|
||||
|
@ -369,6 +372,7 @@ contextBridge.exposeInMainWorld("electron", {
|
|||
lsZip,
|
||||
pendingUploads,
|
||||
setPendingUploads,
|
||||
markUploaded,
|
||||
markUploadedFiles,
|
||||
markUploadedZipEntries,
|
||||
clearPendingUploads,
|
||||
});
|
||||
|
|
|
@ -501,11 +501,16 @@ export interface Electron {
|
|||
setPendingUploads: (pendingUploads: PendingUploads) => Promise<void>;
|
||||
|
||||
/**
|
||||
* Update the list of files (of {@link type}) associated with the pending
|
||||
* upload.
|
||||
* Mark the given files (given by their {@link paths}) as having been
|
||||
* uploaded.
|
||||
*/
|
||||
markUploaded: (
|
||||
pathOrZipEntry: string | [zipPath: string, entryName: string],
|
||||
markUploadedFiles: (paths: PendingUploads["filePaths"]) => Promise<void>;
|
||||
|
||||
/**
|
||||
* Mark the given zip file entries as having been uploaded.
|
||||
*/
|
||||
markUploadedZipEntries: (
|
||||
entries: PendingUploads["zipEntries"],
|
||||
) => Promise<void>;
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue