π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Hook it up
Manav Rathi4e9ff3024cae
diff --git a/desktop/src/main.ts b/desktop/src/main.tsindex 50f69759da..768e1a1df4 100644--- a/desktop/src/main.ts+++ b/desktop/src/main.ts@@ -21,6 +21,7 @@ import {attachFSWatchIPCHandlers,attachIPCHandlers,attachLogoutIPCHandler,+ attachWindowIPCHandlers,} from "./main/ipc";import log, { initLogging } from "./main/log";import { createApplicationMenu, createTrayContextMenu } from "./main/menu";@@ -116,6 +117,7 @@ const main = () => {// Setup IPC and streams.const watcher = createWatcher(mainWindow);attachIPCHandlers();+ attachWindowIPCHandlers(mainWindow);attachFSWatchIPCHandlers(watcher);attachLogoutIPCHandler(watcher);registerStreamProtocol();diff --git a/desktop/src/main/ipc.ts b/desktop/src/main/ipc.tsindex 6e7df7cdea..303ddb6dbd 100644--- a/desktop/src/main/ipc.ts+++ b/desktop/src/main/ipc.ts@@ -9,7 +9,7 @@*/import type { FSWatcher } from "chokidar";-import { ipcMain } from "electron/main";+import { ipcMain, type BrowserWindow } from "electron/main";import type {CollectionMapping,FolderWatch,@@ -19,6 +19,8 @@ import type {import { logToDisk } from "./log";import {appVersion,+ canShowWhatsNew,+ didShowWhatsNew,skipAppUpdate,updateAndRestart,updateOnNextRestart,@@ -117,6 +119,8 @@ export const attachIPCHandlers = () => {ipcMain.on("skipAppUpdate", (_, version: string) => skipAppUpdate(version));+ ipcMain.on("didShowWhatsNew", () => didShowWhatsNew());+// - FSipcMain.handle("fsExists", (_, path: string) => fsExists(path));@@ -216,6 +220,19 @@ export const attachIPCHandlers = () => {ipcMain.handle("clearPendingUploads", () => clearPendingUploads());};+/**+ * Sibling of {@link attachIPCHandlers} that attaches handlers that need access+ * to the main window for their functioning.+ *+ * @param mainWindow Our app's main {@link BrowserWindow}. It is usually needed+ * by these handler to send messages back to the main window's `webContents`.+ */+export const attachWindowIPCHandlers = (mainWindow: BrowserWindow) => {+ // - App update++ ipcMain.on("canShowWhatsNew", () => canShowWhatsNew(mainWindow));+};+/*** Sibling of {@link attachIPCHandlers} that attaches handlers specific to the* watch folder functionality.diff --git a/desktop/src/main/services/app-update.ts b/desktop/src/main/services/app-update.tsindex 8b2d07a49c..c903ea9d0d 100644--- a/desktop/src/main/services/app-update.ts+++ b/desktop/src/main/services/app-update.ts@@ -180,3 +180,27 @@ export const updateOnNextRestart = (version: string) =>export const skipAppUpdate = (version: string) =>userPreferences.set("skipAppVersion", version);++/**+ * Invoked when the renderer attaches a callback for {@link onShowWhatsNew}.+ * This can be taken as a signal that the UI is ready and will be able to show+ * the What's New screen if we need to tell it to.+ *+ * See: [Note: Conditions for showing the "What's new" screen]+ */+export const canShowWhatsNew = (mainWindow: BrowserWindow) => {+ const version = userPreferences.get("whatsNewShownVersion");+ if (version) {+ if (compareVersions(version, app.getVersion()) <= 0) {+ log.debug(() => `Downgrade from ${version}, skipping what's new`);+ return;+ }+ }+ mainWindow.webContents.send("showWhatsNew");+};++/**+ * End the sequence started by {@link canShowWhatsNew}.+ */+export const didShowWhatsNew = () =>+ userPreferences.set("whatsNewShownVersion", app.getVersion());diff --git a/desktop/src/main/stores/user-preferences.ts b/desktop/src/main/stores/user-preferences.tsindex b337b342ac..4b23310ab2 100644--- a/desktop/src/main/stores/user-preferences.ts+++ b/desktop/src/main/stores/user-preferences.ts@@ -9,6 +9,10 @@ interface UserPreferences {hideDockIcon?: boolean;skipAppVersion?: string;muteUpdateNotificationVersion?: string;+ /**+ * The app version for which we last showed the What's New screen.+ */+ whatsNewShownVersion?: string;/*** The last position and size of our app's window.*@@ -33,6 +37,7 @@ const userPreferencesSchema: Schema<UserPreferences> = {hideDockIcon: { type: "boolean" },skipAppVersion: { type: "string" },muteUpdateNotificationVersion: { type: "string" },+ whatsNewShownVersion: { type: "string" },windowBounds: {properties: {x: { type: "number" },diff --git a/desktop/src/preload.ts b/desktop/src/preload.tsindex fe449bad38..9eb2597c0b 100644--- a/desktop/src/preload.ts+++ b/desktop/src/preload.ts@@ -72,12 +72,12 @@ const encryptionKey = () => ipcRenderer.invoke("encryptionKey");const saveEncryptionKey = (encryptionKey: string) =>ipcRenderer.invoke("saveEncryptionKey", encryptionKey);-const onMainWindowFocus = (cb?: () => void) => {+const onMainWindowFocus = (cb: (() => void) | undefined) => {ipcRenderer.removeAllListeners("mainWindowFocus");if (cb) ipcRenderer.on("mainWindowFocus", cb);};-const onOpenURL = (cb?: (url: string) => void) => {+const onOpenURL = (cb: ((url: string) => void) | undefined) => {ipcRenderer.removeAllListeners("openURL");if (cb) ipcRenderer.on("openURL", (_, url: string) => cb(url));};@@ -85,7 +85,7 @@ const onOpenURL = (cb?: (url: string) => void) => {// - App updateconst onAppUpdateAvailable = (- cb?: ((update: AppUpdate) => void) | undefined,+ cb: ((update: AppUpdate) => void) | undefined,) => {ipcRenderer.removeAllListeners("appUpdateAvailable");if (cb) {@@ -104,6 +104,18 @@ const skipAppUpdate = (version: string) => {ipcRenderer.send("skipAppUpdate", version);};+const onShowWhatsNew = (cb: (() => boolean) | undefined) => {+ ipcRenderer.removeAllListeners("showWhatsNew");+ if (cb) {+ ipcRenderer.on("showWhatsNew", () => {+ if (cb()) {+ ipcRenderer.send("didShowWhatsNew");+ }+ });+ ipcRenderer.send("canShowWhatsNew");+ }+};+// - FSconst fsExists = (path: string) => ipcRenderer.invoke("fsExists", path);@@ -320,6 +332,7 @@ contextBridge.exposeInMainWorld("electron", {updateAndRestart,updateOnNextRestart,skipAppUpdate,+ onShowWhatsNew,// - FSdiff --git a/web/packages/next/types/ipc.ts b/web/packages/next/types/ipc.tsindex 2bbfa19bf0..6aa7133d7a 100644--- a/web/packages/next/types/ipc.ts+++ b/web/packages/next/types/ipc.ts@@ -168,7 +168,7 @@ export interface Electron {* that the Node.js layer can update the persisted state to avoid showing it* again.*/- onShowWhatsNew: (cb?: (() => boolean) | undefined) => void;+ onShowWhatsNew: (cb: (() => boolean) | undefined) => void;// - FS