mirror of
https://github.com/SchildiChat/element-web.git
synced 2024-10-01 01:26:12 -04: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
@ -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', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user