desktop: fix auto updater events not sent to app

This commit is contained in:
Abdullah Atta
2023-09-19 16:01:50 +05:00
committed by Abdullah Atta
parent a7011f0d6b
commit 042ac0d338
4 changed files with 32 additions and 25 deletions

View File

@@ -0,0 +1,3 @@
owner: streetwriters
repo: notesnook
provider: github

View File

@@ -191,6 +191,7 @@
"allowNativeWayland": true "allowNativeWayland": true
}, },
"extraResources": [ "extraResources": [
"app-update.yml",
"./assets/**" "./assets/**"
], ],
"extraMetadata": { "extraMetadata": {

View File

@@ -90,6 +90,7 @@ async function createWindow() {
} }
}); });
createIPCHandler({ router, windows: [mainWindow] });
globalThis.window = mainWindow; globalThis.window = mainWindow;
mainWindowState.manage(mainWindow); mainWindowState.manage(mainWindow);
@@ -105,7 +106,6 @@ async function createWindow() {
await AssetManager.loadIcons(); await AssetManager.loadIcons();
setupDesktopIntegration(); setupDesktopIntegration();
createIPCHandler({ router, windows: [mainWindow] });
mainWindow.webContents.session.setSpellCheckerDictionaryDownloadURL( mainWindow.webContents.session.setSpellCheckerDictionaryDownloadURL(
"http://dictionaries.notesnook.com/" "http://dictionaries.notesnook.com/"

View File

@@ -21,40 +21,43 @@ import { createTRPCProxyClient } from "@trpc/client";
import { ipcLink } from "electron-trpc/renderer"; import { ipcLink } from "electron-trpc/renderer";
import type { AppRouter } from "@notesnook/desktop"; import type { AppRouter } from "@notesnook/desktop";
import { AppEventManager, AppEvents } from "../app-events"; import { AppEventManager, AppEvents } from "../app-events";
import { checkForUpdate } from "../../utils/updater";
export const desktop = createTRPCProxyClient<AppRouter>({ export const desktop = createTRPCProxyClient<AppRouter>({
links: [ipcLink()] links: [ipcLink()]
}); });
desktop.updater.onChecking.subscribe( document.addEventListener("readystatechange", async () => {
undefined, desktop.updater.onChecking.subscribe(
attachListener(AppEvents.checkingForUpdate) undefined,
); attachListener(AppEvents.checkingForUpdate)
);
desktop.updater.onAvailable.subscribe( desktop.updater.onAvailable.subscribe(
undefined, undefined,
attachListener(AppEvents.updateAvailable) attachListener(AppEvents.updateAvailable)
); );
desktop.updater.onDownloaded.subscribe( desktop.updater.onDownloaded.subscribe(
undefined, undefined,
attachListener(AppEvents.updateDownloadCompleted) attachListener(AppEvents.updateDownloadCompleted)
); );
desktop.updater.onDownloadProgress.subscribe( desktop.updater.onDownloadProgress.subscribe(
undefined, undefined,
attachListener(AppEvents.updateDownloadProgress) attachListener(AppEvents.updateDownloadProgress)
); );
desktop.updater.onNotAvailable.subscribe( desktop.updater.onNotAvailable.subscribe(
undefined, undefined,
attachListener(AppEvents.updateNotAvailable) attachListener(AppEvents.updateNotAvailable)
); );
desktop.updater.onError.subscribe( desktop.updater.onError.subscribe(
undefined, undefined,
attachListener(AppEvents.updateError) attachListener(AppEvents.updateError)
); );
});
function attachListener(event: string) { function attachListener(event: string) {
return { return {