From 0ad585d64717da626f4319f0d471b83e2a61808b Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Sat, 2 May 2020 17:23:35 +0200 Subject: [PATCH] don't open second window on app restart when in dock mode (fixes #2449) --- app/lib/app.ts | 7 +++++++ app/lib/index.ts | 3 +-- app/lib/window.ts | 7 +++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/lib/app.ts b/app/lib/app.ts index 6a6eb05f..a1c016c8 100644 --- a/app/lib/app.ts +++ b/app/lib/app.ts @@ -137,6 +137,13 @@ export class Application { } } + handleSecondInstance (argv: string[], cwd: string): void { + this.presentAllWindows() + for (let window of this.windows) { + window.handleSecondInstance(argv, cwd) + } + } + private setupMenu () { let template: Electron.MenuItemConstructorOptions[] = [ { diff --git a/app/lib/index.ts b/app/lib/index.ts index 464dd897..49f08dc0 100644 --- a/app/lib/index.ts +++ b/app/lib/index.ts @@ -34,8 +34,7 @@ process.on('uncaughtException' as any, err => { }) app.on('second-instance', (_event, argv, cwd) => { - application.presentAllWindows() - application.send('host:second-instance', parseArgs(argv, cwd), cwd) + application.handleSecondInstance(argv, cwd) }) const argv = parseArgs(process.argv, process.cwd()) diff --git a/app/lib/window.ts b/app/lib/window.ts index 253a0b0f..ce861c43 100644 --- a/app/lib/window.ts +++ b/app/lib/window.ts @@ -5,6 +5,7 @@ import ElectronConfig = require('electron-config') import * as os from 'os' import * as path from 'path' +import { parseArgs } from './cli' import { loadConfig } from './config' let SetWindowCompositionAttribute: any @@ -210,6 +211,12 @@ export class Window { } } + handleSecondInstance (argv: string[], cwd: string): void { + if (!this.configStore.appearance?.dock) { + this.send('host:second-instance', parseArgs(argv, cwd), cwd) + } + } + private setupWindowManagement () { this.window.on('show', () => { this.visible.next(true) -- GitLab