File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change 11import { shell } from "electron/common" ;
22import { app , dialog , session } from "electron/main" ;
33import process from "node:process" ;
4- import util from "node:util" ;
54
65import log from "electron-log" ;
76import type { UpdateDownloadedEvent , UpdateInfo } from "electron-updater" ;
@@ -11,7 +10,11 @@ import * as ConfigUtil from "../common/config-util";
1110
1211import { linuxUpdateNotification } from "./linuxupdater" ; // Required only in case of linux
1312
14- const sleep = util . promisify ( setTimeout ) ;
13+ let quitting = false ;
14+
15+ export function shouldQuitForUpdate ( ) : boolean {
16+ return quitting ;
17+ }
1518
1619export async function appUpdater ( updateFromMenu = false ) : Promise < void > {
1720 // Don't initiate auto-updates in development
@@ -104,10 +107,8 @@ Current Version: ${app.getVersion()}`,
104107 detail : "It will be installed the next time you restart the application" ,
105108 } ) ;
106109 if ( response === 0 ) {
107- await sleep ( 1000 ) ;
110+ quitting = true ;
108111 autoUpdater . quitAndInstall ( ) ;
109- // Force app to quit. This is just a workaround, ideally autoUpdater.quitAndInstall() should relaunch the app.
110- app . quit ( ) ;
111112 }
112113 } ) ;
113114 // Init for updates
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import * as ConfigUtil from "../common/config-util";
1010import type { RendererMessage } from "../common/typed-ipc" ;
1111import type { MenuProps } from "../common/types" ;
1212
13- import { appUpdater } from "./autoupdater" ;
13+ import { appUpdater , shouldQuitForUpdate } from "./autoupdater" ;
1414import * as BadgeSettings from "./badge-settings" ;
1515import handleExternalLink from "./handle-external-link" ;
1616import * as AppMenu from "./menu" ;
@@ -91,7 +91,7 @@ function createMainWindow(): BrowserWindow {
9191 app . quit ( ) ;
9292 }
9393
94- if ( ! isQuitting ) {
94+ if ( ! isQuitting && ! shouldQuitForUpdate ( ) ) {
9595 event . preventDefault ( ) ;
9696
9797 if ( process . platform === "darwin" ) {
You can’t perform that action at this time.
0 commit comments