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 1
1
import { shell } from "electron/common" ;
2
2
import { app , dialog , session } from "electron/main" ;
3
3
import process from "node:process" ;
4
- import util from "node:util" ;
5
4
6
5
import log from "electron-log" ;
7
6
import type { UpdateDownloadedEvent , UpdateInfo } from "electron-updater" ;
@@ -11,7 +10,11 @@ import * as ConfigUtil from "../common/config-util";
11
10
12
11
import { linuxUpdateNotification } from "./linuxupdater" ; // Required only in case of linux
13
12
14
- const sleep = util . promisify ( setTimeout ) ;
13
+ let quitting = false ;
14
+
15
+ export function shouldQuitForUpdate ( ) : boolean {
16
+ return quitting ;
17
+ }
15
18
16
19
export async function appUpdater ( updateFromMenu = false ) : Promise < void > {
17
20
// Don't initiate auto-updates in development
@@ -104,10 +107,8 @@ Current Version: ${app.getVersion()}`,
104
107
detail : "It will be installed the next time you restart the application" ,
105
108
} ) ;
106
109
if ( response === 0 ) {
107
- await sleep ( 1000 ) ;
110
+ quitting = true ;
108
111
autoUpdater . quitAndInstall ( ) ;
109
- // Force app to quit. This is just a workaround, ideally autoUpdater.quitAndInstall() should relaunch the app.
110
- app . quit ( ) ;
111
112
}
112
113
} ) ;
113
114
// Init for updates
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import * as ConfigUtil from "../common/config-util";
10
10
import type { RendererMessage } from "../common/typed-ipc" ;
11
11
import type { MenuProps } from "../common/types" ;
12
12
13
- import { appUpdater } from "./autoupdater" ;
13
+ import { appUpdater , shouldQuitForUpdate } from "./autoupdater" ;
14
14
import * as BadgeSettings from "./badge-settings" ;
15
15
import handleExternalLink from "./handle-external-link" ;
16
16
import * as AppMenu from "./menu" ;
@@ -91,7 +91,7 @@ function createMainWindow(): BrowserWindow {
91
91
app . quit ( ) ;
92
92
}
93
93
94
- if ( ! isQuitting ) {
94
+ if ( ! isQuitting && ! shouldQuitForUpdate ( ) ) {
95
95
event . preventDefault ( ) ;
96
96
97
97
if ( process . platform === "darwin" ) {
You can’t perform that action at this time.
0 commit comments