Move more standalone methods to preload
This commit is contained in:
parent
b3289f2b8d
commit
3ce8513e48
3 changed files with 43 additions and 47 deletions
|
@ -1,30 +1,5 @@
|
|||
import { ipcRenderer } from "electron/renderer";
|
||||
import { logError } from "../services/logging";
|
||||
|
||||
export const selectDirectory = async (): Promise<string> => {
|
||||
try {
|
||||
return await ipcRenderer.invoke("select-dir");
|
||||
} catch (e) {
|
||||
logError(e, "error while selecting root directory");
|
||||
}
|
||||
};
|
||||
|
||||
export const getAppVersion = async (): Promise<string> => {
|
||||
try {
|
||||
return await ipcRenderer.invoke("get-app-version");
|
||||
} catch (e) {
|
||||
logError(e, "failed to get release version");
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
export const openDirectory = async (dirPath: string): Promise<void> => {
|
||||
try {
|
||||
await ipcRenderer.invoke("open-dir", dirPath);
|
||||
} catch (e) {
|
||||
logError(e, "error while opening directory");
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
export { logToDisk, openLogDirectory } from "../services/logging";
|
||||
|
|
|
@ -16,15 +16,3 @@ export const registerForegroundEventListener = (onForeground: () => void) => {
|
|||
onForeground();
|
||||
});
|
||||
};
|
||||
|
||||
export const updateAndRestart = () => {
|
||||
ipcRenderer.send("update-and-restart");
|
||||
};
|
||||
|
||||
export const skipAppUpdate = (version: string) => {
|
||||
ipcRenderer.send("skip-app-update", version);
|
||||
};
|
||||
|
||||
export const muteUpdateNotification = (version: string) => {
|
||||
ipcRenderer.send("mute-update-notification", version);
|
||||
};
|
||||
|
|
|
@ -33,13 +33,7 @@ import path from "path";
|
|||
import * as fs from "promise-fs";
|
||||
import { Readable } from "stream";
|
||||
import { deleteDiskCache, openDiskCache } from "./api/cache";
|
||||
import {
|
||||
getAppVersion,
|
||||
logToDisk,
|
||||
openDirectory,
|
||||
openLogDirectory,
|
||||
selectDirectory,
|
||||
} from "./api/common";
|
||||
import { logToDisk, openLogDirectory } from "./api/common";
|
||||
import { clearElectronStore } from "./api/electronStore";
|
||||
import {
|
||||
checkExistsAndCreateDir,
|
||||
|
@ -52,11 +46,8 @@ import { getDirFiles } from "./api/fs";
|
|||
import { convertToJPEG, generateImageThumbnail } from "./api/imageProcessor";
|
||||
import { getEncryptionKey, setEncryptionKey } from "./api/safeStorage";
|
||||
import {
|
||||
muteUpdateNotification,
|
||||
registerForegroundEventListener,
|
||||
registerUpdateEventListener,
|
||||
skipAppUpdate,
|
||||
updateAndRestart,
|
||||
} from "./api/system";
|
||||
import {
|
||||
getElectronFilesFromGoogleZip,
|
||||
|
@ -313,6 +304,48 @@ const parseExecError = (err: any) => {
|
|||
|
||||
// -
|
||||
|
||||
const selectDirectory = async (): Promise<string> => {
|
||||
try {
|
||||
return await ipcRenderer.invoke("select-dir");
|
||||
} catch (e) {
|
||||
logError(e, "error while selecting root directory");
|
||||
}
|
||||
};
|
||||
|
||||
const getAppVersion = async (): Promise<string> => {
|
||||
try {
|
||||
return await ipcRenderer.invoke("get-app-version");
|
||||
} catch (e) {
|
||||
logError(e, "failed to get release version");
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
const openDirectory = async (dirPath: string): Promise<void> => {
|
||||
try {
|
||||
await ipcRenderer.invoke("open-dir", dirPath);
|
||||
} catch (e) {
|
||||
logError(e, "error while opening directory");
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
// -
|
||||
|
||||
const updateAndRestart = () => {
|
||||
ipcRenderer.send("update-and-restart");
|
||||
};
|
||||
|
||||
const skipAppUpdate = (version: string) => {
|
||||
ipcRenderer.send("skip-app-update", version);
|
||||
};
|
||||
|
||||
const muteUpdateNotification = (version: string) => {
|
||||
ipcRenderer.send("mute-update-notification", version);
|
||||
};
|
||||
|
||||
// -
|
||||
|
||||
setupLogging();
|
||||
|
||||
// These objects exposed here will become available to the JS code in our
|
||||
|
|
Loading…
Reference in a new issue