diff --git a/materialious/electron/src/index.ts b/materialious/electron/src/index.ts index 476b8cd3..9b395569 100644 --- a/materialious/electron/src/index.ts +++ b/materialious/electron/src/index.ts @@ -58,8 +58,6 @@ let allowInsecureSSL = false; setupContentSecurityPolicy(myCapacitorApp.getCustomURLScheme()); // Initialize our app, build windows, and load content. await myCapacitorApp.init(); - // Check for updates if we are in a packaged app. - autoUpdater.checkForUpdatesAndNotify(); })(); app.on('certificate-error', (event, webContents, url, error, certificate, callback) => { @@ -167,3 +165,17 @@ ipcMain.handle('setAllowInsecureSSL', async (_, allow) => { return allowInsecureSSL; }); + +ipcMain.handle('doUpdateCheck', async (_, disableAutoUpdate) => { + // Check for updates if we are in a packaged app. + autoUpdater.autoInstallOnAppQuit = !disableAutoUpdate; + + if (disableAutoUpdate) { + await autoUpdater.checkForUpdatesAndNotify({ + title: 'Update Available', + body: 'A new version is available.' + }); + } else { + await autoUpdater.checkForUpdatesAndNotify(); + } +}); diff --git a/materialious/src/lib/components/Settings/Interface.svelte b/materialious/src/lib/components/Settings/Interface.svelte index 9f17b996..4a163a61 100644 --- a/materialious/src/lib/components/Settings/Interface.svelte +++ b/materialious/src/lib/components/Settings/Interface.svelte @@ -21,6 +21,7 @@ interfaceAutoExpandComments, interfaceAutoExpandDesc, interfaceDefaultPage, + interfaceDisableAutoUpdate, interfaceForceCase, interfaceLowBandwidthMode, interfaceRegionStore, @@ -110,6 +111,12 @@ } }); + if (Capacitor.getPlatform() === 'electron') { + interfaceDisableAutoUpdate.subscribe((isDisabled) => { + window.electronAPI.doUpdateCheck(isDisabled); + }); + } + let pages: Pages = $state([]); authStore.subscribe(() => { pages = getPages(); @@ -288,6 +295,24 @@ +{#if Capacitor.getPlatform() == 'electron'} +
+ +
+{/if} +