@@ -6,7 +6,7 @@ import { listPinnedProjects, registerIpcHandlers } from './ipc.js';
66import { initAutoUpdater } from './auto-update.js' ;
77import { getAppBehaviorPrefs , loadPrefs } from './prefs.js' ;
88import { installAppMenu , handleMenuCheckForUpdates } from './menu.js' ;
9- import { registerQuitPrompt } from './quit-prompt.js' ;
9+ import { isInstallingDownloadedUpdate , registerQuitPrompt } from './quit-prompt.js' ;
1010import { installTray } from './tray.js' ;
1111import {
1212 getShortcutRegistrationStatuses ,
@@ -80,6 +80,15 @@ function quitApp(): void {
8080 app . quit ( ) ;
8181}
8282
83+ function shouldHideWindowInsteadOfClosing ( ) : boolean {
84+ const prefs = getAppBehaviorPrefs ( ) ;
85+ return (
86+ prefs . menu_bar_persistence_enabled &&
87+ ! isQuitting &&
88+ ! isInstallingDownloadedUpdate ( )
89+ ) ;
90+ }
91+
8392function refreshTray ( ) : void {
8493 installTray ( {
8594 showWindow,
@@ -144,17 +153,15 @@ function createWindow(): void {
144153 } ) ;
145154
146155 mainWindow . on ( 'close' , ( event ) => {
147- const prefs = getAppBehaviorPrefs ( ) ;
148- if ( prefs . menu_bar_persistence_enabled && ! isQuitting ) {
156+ if ( shouldHideWindowInsteadOfClosing ( ) ) {
149157 event . preventDefault ( ) ;
150158 mainWindow ?. hide ( ) ;
151159 updateDockVisibility ( ) ;
152160 }
153161 } ) ;
154162
155163 onPreventableMinimize ( mainWindow , ( event ) => {
156- const prefs = getAppBehaviorPrefs ( ) ;
157- if ( prefs . menu_bar_persistence_enabled ) {
164+ if ( shouldHideWindowInsteadOfClosing ( ) ) {
158165 event . preventDefault ( ) ;
159166 mainWindow ?. hide ( ) ;
160167 updateDockVisibility ( ) ;
@@ -219,7 +226,11 @@ app.on('will-quit', () => {
219226} ) ;
220227
221228app . on ( 'window-all-closed' , ( ) => {
222- if ( ! getAppBehaviorPrefs ( ) . menu_bar_persistence_enabled || isQuitting ) {
229+ if (
230+ ! getAppBehaviorPrefs ( ) . menu_bar_persistence_enabled ||
231+ isQuitting ||
232+ isInstallingDownloadedUpdate ( )
233+ ) {
223234 app . quit ( ) ;
224235 } else {
225236 updateDockVisibility ( ) ;
0 commit comments