mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-02-21 02:33:34 +01:00
get update status on start, install update on quit
This commit is contained in:
parent
5f229048be
commit
61f02b27d2
@ -731,6 +731,7 @@ electronApp.on("window-all-closed", () => {
|
||||
});
|
||||
electronApp.on("before-quit", () => {
|
||||
globalIsQuitting = true;
|
||||
updater?.installUpdate();
|
||||
});
|
||||
process.on("SIGINT", () => {
|
||||
console.log("Caught SIGINT, shutting down");
|
||||
|
@ -47,7 +47,7 @@ export class Updater {
|
||||
body: "A new version of Wave Terminal is ready to install.",
|
||||
});
|
||||
updateNotification.on("click", () => {
|
||||
fireAndForget(() => this.installAppUpdate());
|
||||
fireAndForget(() => this.promptToInstallUpdate());
|
||||
});
|
||||
updateNotification.show();
|
||||
});
|
||||
@ -130,7 +130,7 @@ export class Updater {
|
||||
/**
|
||||
* Prompts the user to install the downloaded application update and restarts the application
|
||||
*/
|
||||
async installAppUpdate() {
|
||||
async promptToInstallUpdate() {
|
||||
const dialogOpts: Electron.MessageBoxOptions = {
|
||||
type: "info",
|
||||
buttons: ["Restart", "Later"],
|
||||
@ -145,15 +145,24 @@ export class Updater {
|
||||
.showMessageBox(electron.BrowserWindow.getFocusedWindow() ?? allWindows[0], dialogOpts)
|
||||
.then(({ response }) => {
|
||||
if (response === 0) {
|
||||
this.status = "installing";
|
||||
autoUpdater.quitAndInstall();
|
||||
this.installUpdate();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restarts the app and installs an update if it is available.
|
||||
*/
|
||||
installUpdate() {
|
||||
if (this.status == "ready") {
|
||||
this.status = "installing";
|
||||
autoUpdater.quitAndInstall();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
electron.ipcMain.on("install-app-update", () => fireAndForget(() => updater?.installAppUpdate()));
|
||||
electron.ipcMain.on("install-app-update", () => fireAndForget(() => updater?.promptToInstallUpdate()));
|
||||
electron.ipcMain.on("get-app-update-status", (event) => {
|
||||
event.returnValue = updater?.status;
|
||||
});
|
||||
|
@ -106,6 +106,7 @@ function initGlobalAtoms(initOpts: GlobalInitOptions) {
|
||||
const cmdShiftDelayAtom = jotai.atom(false);
|
||||
const updateStatusAtom = jotai.atom<UpdaterStatus>("up-to-date") as jotai.PrimitiveAtom<UpdaterStatus>;
|
||||
try {
|
||||
globalStore.set(updateStatusAtom, getApi().getUpdaterStatus());
|
||||
getApi().onUpdaterStatusChange((status) => {
|
||||
console.log("updater status change", status);
|
||||
globalStore.set(updateStatusAtom, status);
|
||||
|
Loading…
Reference in New Issue
Block a user