Various updater fixes (#1170)

- Fixes updater status not showing on tabs that were previously
unloaded.
- Fixes updater status showing as error when not connected to the
internet
- Adds delay after setting installing status to avoid race condition
with any window close event handlers. This may fix #1167
This commit is contained in:
Evan Simkowitz 2024-10-30 14:20:19 -07:00 committed by GitHub
parent 17adf7b2c3
commit b3fdbbc331
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View File

@ -10,6 +10,7 @@ import { FileService } from "../frontend/app/store/services";
import { RpcApi } from "../frontend/app/store/wshclientapi";
import { isDev } from "../frontend/util/isdev";
import { fireAndForget } from "../frontend/util/util";
import { delay } from "./emain-util";
import { getAllWaveWindows, getFocusedWaveWindow } from "./emain-viewmgr";
import { ElectronWshClient } from "./emain-wsh";
@ -65,7 +66,7 @@ export class Updater {
autoUpdater.on("error", (err) => {
console.log("updater error");
console.log(err);
this.status = "error";
if (!err.message.includes("net::ERR_INTERNET_DISCONNECTED")) this.status = "error";
});
autoUpdater.on("checking-for-update", () => {
@ -188,7 +189,7 @@ export class Updater {
const focusedWindow = getFocusedWaveWindow();
await dialog.showMessageBox(focusedWindow ?? allWindows[0], dialogOpts).then(({ response }) => {
if (response === 0) {
this.installUpdate();
fireAndForget(async () => this.installUpdate());
}
});
}
@ -197,9 +198,10 @@ export class Updater {
/**
* Restarts the app and installs an update if it is available.
*/
installUpdate() {
async installUpdate() {
if (this.status == "ready") {
this.status = "installing";
await delay(1000);
autoUpdater.quitAndInstall();
}
}

View File

@ -92,6 +92,7 @@ async function reinitWave() {
document.title = `Wave Terminal - ${initialTab.name}`; // TODO update with tab name change
getApi().setWindowInitStatus("wave-ready");
globalStore.set(atoms.reinitVersion, globalStore.get(atoms.reinitVersion) + 1);
globalStore.set(atoms.updaterStatusAtom, getApi().getUpdaterStatus());
}
function reloadAllWorkspaceTabs(ws: Workspace) {