Skip to content

armgit / ente

Public Imported from GitHub
0

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

Move more standalone methods to preload

Manav Rathi3ce8513e488a
diff --git a/desktop/src/api/common.ts b/desktop/src/api/common.ts
index 0c4c69cbe9..64a1bbdfff 100644
--- a/desktop/src/api/common.ts
+++ b/desktop/src/api/common.ts
@@ -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";
diff --git a/desktop/src/api/system.ts b/desktop/src/api/system.ts
index 11e52d0554..422df34ae5 100644
--- a/desktop/src/api/system.ts
+++ b/desktop/src/api/system.ts
@@ -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);
-};
diff --git a/desktop/src/preload.ts b/desktop/src/preload.ts
index e60fe91e69..a0cbec7f13 100644
--- a/desktop/src/preload.ts
+++ b/desktop/src/preload.ts
@@ -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