Skip to content

Commit 2a1a865

Browse files
committed
fix windows11 app window not shown
1 parent 496d913 commit 2a1a865

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

src/main/index.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ export default class DeskreenApp {
117117
}
118118
});
119119

120-
app.whenReady().then(async () => {
120+
// ensure window creation happens even if app.whenReady() has already fired
121+
const initializeApp = async (): Promise<void> => {
121122
app.setAppUserModelId('com.deskreen-ce.app');
122123
app.setActivationPolicy('regular');
123124

@@ -127,7 +128,17 @@ export default class DeskreenApp {
127128
await this.createWindow();
128129

129130
void this.checkForLatestVersionAndNotify();
130-
});
131+
};
132+
133+
if (app.isReady()) {
134+
// app is already ready, initialize immediately
135+
void initializeApp();
136+
} else {
137+
// app is not ready yet, wait for it
138+
app.whenReady().then(initializeApp).catch((error) => {
139+
console.error('Failed to initialize app:', error);
140+
});
141+
}
131142

132143
app.on('browser-window-created', (_, window) => {
133144
optimizer.watchWindowShortcuts(window);
@@ -304,12 +315,25 @@ export default class DeskreenApp {
304315
}
305316
this.mainWindow.focus();
306317
this.mainWindow.show();
318+
} else {
319+
// window was never created or was closed, create it now
320+
if (app.isReady()) {
321+
void this.createWindow();
322+
} else {
323+
app.whenReady().then(() => {
324+
void this.createWindow();
325+
});
326+
}
307327
}
308328
});
309329

310330
const cliLocalIp = this.parseCliLocalIp();
311331
initGlobals(join(__dirname, '..'), cliLocalIp);
312-
signalingServer.start();
332+
333+
// start signaling server with error handling to prevent unhandled promise rejections
334+
void signalingServer.start().catch((error) => {
335+
console.error('Failed to start signaling server:', error);
336+
});
313337

314338
this.initElectronAppObject();
315339
}

0 commit comments

Comments
 (0)