refactor hidden logic to be more resilient against electron weirdness

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
pull/6805/head
Michael Telatynski 2018-05-26 14:21:38 +01:00
parent ca2533cafa
commit 8a4a6b2023
No known key found for this signature in database
GPG Key ID: 3F879DA5AD802A5E
1 changed files with 13 additions and 5 deletions

View File

@ -101,6 +101,9 @@ electron.ipcMain.on('app_onAction', function(ev, payload) {
electron.app.commandLine.appendSwitch('--enable-usermedia-screen-capturing');
const shouldQuit = electron.app.makeSingleInstance((commandLine, workingDirectory) => {
// If other instance launched with --hidden then skip showing window
if (commandLine.includes('--hidden')) return;
// Someone tried to run a second instance, we should focus our window.
if (mainWindow) {
if (!mainWindow.isVisible()) mainWindow.show();
@ -211,11 +214,17 @@ electron.app.on('ready', () => {
brand: vectorConfig.brand || 'Riot',
});
if (!argv.hidden) {
mainWindow.once('ready-to-show', () => {
mainWindowState.manage(mainWindow);
if (!argv.hidden) {
console.log("Showing window");
mainWindow.show();
});
} else {
// hide here explicitly because window manage above sometimes shows it
mainWindow.hide();
}
});
mainWindow.on('closed', () => {
mainWindow = global.mainWindow = null;
@ -243,7 +252,6 @@ electron.app.on('ready', () => {
}
webContentsHandler(mainWindow.webContents);
mainWindowState.manage(mainWindow);
});
electron.app.on('window-all-closed', () => {