Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

desktop: fix auto updater events not sent to app

Abdullah Atta042ac0d338e1
diff --git a/apps/desktop/app-update.yml b/apps/desktop/app-update.yml
new file mode 100644
index 000000000..6996f8654
--- /dev/null
+++ b/apps/desktop/app-update.yml
@@ -0,0 +1,3 @@
+owner: streetwriters
+repo: notesnook
+provider: github
diff --git a/apps/desktop/package.json b/apps/desktop/package.json
index 5f7da1c16..1ac8d1093 100644
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@ -191,6 +191,7 @@
"allowNativeWayland": true
},
"extraResources": [
+ "app-update.yml",
"./assets/**"
],
"extraMetadata": {
diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.ts
index a62e737d0..c02c836cb 100644
--- a/apps/desktop/src/main.ts
+++ b/apps/desktop/src/main.ts
@@ -90,6 +90,7 @@ async function createWindow() {
}
});
+ createIPCHandler({ router, windows: [mainWindow] });
globalThis.window = mainWindow;
mainWindowState.manage(mainWindow);
@@ -105,7 +106,6 @@ async function createWindow() {
await AssetManager.loadIcons();
setupDesktopIntegration();
- createIPCHandler({ router, windows: [mainWindow] });
mainWindow.webContents.session.setSpellCheckerDictionaryDownloadURL(
"http://dictionaries.notesnook.com/"
diff --git a/apps/web/src/common/desktop-bridge/index.desktop.ts b/apps/web/src/common/desktop-bridge/index.desktop.ts
index 9bb6eff7f..920044399 100644
--- a/apps/web/src/common/desktop-bridge/index.desktop.ts
+++ b/apps/web/src/common/desktop-bridge/index.desktop.ts
@@ -21,40 +21,43 @@ import { createTRPCProxyClient } from "@trpc/client";
import { ipcLink } from "electron-trpc/renderer";
import type { AppRouter } from "@notesnook/desktop";
import { AppEventManager, AppEvents } from "../app-events";
+import { checkForUpdate } from "../../utils/updater";
export const desktop = createTRPCProxyClient<AppRouter>({
links: [ipcLink()]
});
-desktop.updater.onChecking.subscribe(
- undefined,
- attachListener(AppEvents.checkingForUpdate)
-);
+document.addEventListener("readystatechange", async () => {
+ desktop.updater.onChecking.subscribe(
+ undefined,
+ attachListener(AppEvents.checkingForUpdate)
+ );
-desktop.updater.onAvailable.subscribe(
- undefined,
- attachListener(AppEvents.updateAvailable)
-);
+ desktop.updater.onAvailable.subscribe(
+ undefined,
+ attachListener(AppEvents.updateAvailable)
+ );
-desktop.updater.onDownloaded.subscribe(
- undefined,
- attachListener(AppEvents.updateDownloadCompleted)
-);
+ desktop.updater.onDownloaded.subscribe(
+ undefined,
+ attachListener(AppEvents.updateDownloadCompleted)
+ );
-desktop.updater.onDownloadProgress.subscribe(
- undefined,
- attachListener(AppEvents.updateDownloadProgress)
-);
+ desktop.updater.onDownloadProgress.subscribe(
+ undefined,
+ attachListener(AppEvents.updateDownloadProgress)
+ );
-desktop.updater.onNotAvailable.subscribe(
- undefined,
- attachListener(AppEvents.updateNotAvailable)
-);
+ desktop.updater.onNotAvailable.subscribe(
+ undefined,
+ attachListener(AppEvents.updateNotAvailable)
+ );
-desktop.updater.onError.subscribe(
- undefined,
- attachListener(AppEvents.updateError)
-);
+ desktop.updater.onError.subscribe(
+ undefined,
+ attachListener(AppEvents.updateError)
+ );
+});
function attachListener(event: string) {
return {