From 21684b0995a5f3bb20b1516354fb9b6cd0c899c4 Mon Sep 17 00:00:00 2001 From: Evan Simkowitz Date: Tue, 6 Aug 2024 16:30:42 -0700 Subject: [PATCH] use native install on quit instead --- emain/emain.ts | 2 +- emain/updater.ts | 7 ++++--- frontend/types/gotypes.d.ts | 1 + pkg/wconfig/settingsconfig.go | 10 ++++++---- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/emain/emain.ts b/emain/emain.ts index af989f460..71d6a9343 100644 --- a/emain/emain.ts +++ b/emain/emain.ts @@ -731,7 +731,6 @@ electronApp.on("window-all-closed", () => { }); electronApp.on("before-quit", () => { globalIsQuitting = true; - updater?.installUpdate(); }); process.on("SIGINT", () => { console.log("Caught SIGINT, shutting down"); @@ -809,6 +808,7 @@ async function appMain() { await electronApp.whenReady(); await relaunchBrowserWindows(); await configureAutoUpdater(); + globalIsStarting = false; electronApp.on("activate", async () => { diff --git a/emain/updater.ts b/emain/updater.ts index a8bacf5a7..ec1e7c377 100644 --- a/emain/updater.ts +++ b/emain/updater.ts @@ -187,23 +187,24 @@ export async function configureAutoUpdater() { autoUpdateLock = true; - const autoUpdateEnabled = (await services.FileService.GetSettingsConfig()).autoupdate.enabled; + const autoUpdateOpts = (await services.FileService.GetSettingsConfig()).autoupdate; try { console.log("Configuring updater"); updater = new Updater(); + autoUpdater.autoInstallOnAppQuit = autoUpdateOpts.installonquit; } catch (e) { console.warn("error configuring updater", e.toString()); } - if (autoUpdateEnabled && updater?.interval == null) { + if (autoUpdateOpts.enabled && updater?.interval == null) { try { console.log("configuring auto update interval"); updater?.startInterval(); } catch (e) { console.log("error configuring auto update interval", e.toString()); } - } else if (!autoUpdateEnabled && updater?.interval != null) { + } else if (!autoUpdateOpts.enabled && updater?.interval != null) { console.log("disabling auto updater"); clearInterval(updater.interval); updater = null; diff --git a/frontend/types/gotypes.d.ts b/frontend/types/gotypes.d.ts index 17485bde5..052eda94f 100644 --- a/frontend/types/gotypes.d.ts +++ b/frontend/types/gotypes.d.ts @@ -19,6 +19,7 @@ declare global { type AutoUpdateOpts = { enabled: boolean; intervalms: number; + installonquit: boolean; }; // wstore.Block diff --git a/pkg/wconfig/settingsconfig.go b/pkg/wconfig/settingsconfig.go index 41a9e48e4..fd63aa353 100644 --- a/pkg/wconfig/settingsconfig.go +++ b/pkg/wconfig/settingsconfig.go @@ -48,8 +48,9 @@ type BlockHeaderOpts struct { } type AutoUpdateOpts struct { - Enabled bool `json:"enabled"` - IntervalMs uint32 `json:"intervalms"` + Enabled bool `json:"enabled"` + IntervalMs uint32 `json:"intervalms"` + InstallOnQuit bool `json:"installonquit"` } type TermThemeType struct { @@ -245,8 +246,9 @@ func applyDefaultSettings(settings *SettingsConfigType) { } if settings.AutoUpdate == nil { settings.AutoUpdate = &AutoUpdateOpts{ - Enabled: true, - IntervalMs: 3600000, + Enabled: true, + InstallOnQuit: true, + IntervalMs: 3600000, } } var userName string