mirror of
https://github.com/element-hq/element-web
synced 2024-11-28 04:21:57 +03:00
refactor hidden logic to be more resilient against electron weirdness
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
ca2533cafa
commit
8a4a6b2023
1 changed files with 13 additions and 5 deletions
|
@ -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', () => {
|
||||
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', () => {
|
||||
|
|
Loading…
Reference in a new issue