@@ -132,10 +132,27 @@ app.whenReady().then(async () => {
132
132
133
133
setupMenu ( )
134
134
135
- const focusMainWindow = ( ) => {
135
+ /**
136
+ * Focus the main window. Restore/re-create it if needed.
137
+ */
138
+ function focusMainWindow ( ) {
139
+ // There is no main window at all, the app is not initialized yet - ignore
140
+ if ( ! createMainWindow ) {
141
+ return
142
+ }
143
+
144
+ // There is no window (possible on macOS) - create
145
+ if ( ! mainWindow || mainWindow . isDestroyed ( ) ) {
146
+ mainWindow = createMainWindow ( )
147
+ mainWindow . once ( 'ready-to-show' , ( ) => mainWindow . show ( ) )
148
+ return
149
+ }
150
+
151
+ // The window is minimized - restore
136
152
if ( mainWindow . isMinimized ( ) ) {
137
153
mainWindow . restore ( )
138
154
}
155
+
139
156
// Show the window in case it is hidden in the system tray and focus it
140
157
mainWindow . show ( )
141
158
}
@@ -214,10 +231,13 @@ app.whenReady().then(async () => {
214
231
*/
215
232
} )
216
233
217
- const welcomeWindow = createWelcomeWindow ( )
218
- welcomeWindow . once ( 'ready-to-show' , ( ) => welcomeWindow . show ( ) )
234
+ mainWindow = createWelcomeWindow ( )
235
+ createMainWindow = createWelcomeWindow
236
+ mainWindow . once ( 'ready-to-show' , ( ) => mainWindow . show ( ) )
219
237
220
238
ipcMain . once ( 'appData:receive' , async ( event , appData ) => {
239
+ const welcomeWindow = mainWindow
240
+
221
241
if ( appData . credentials ) {
222
242
// User is authenticated - setup and start main window
223
243
enableWebRequestInterceptor ( appData . serverUrl , {
0 commit comments