From 1513b25a350c9dfd855410d3f8f2cfbf70744d01 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 5 Aug 2020 10:53:26 -0400 Subject: [PATCH] callbacks for argv from window main (#141) --- src/angular/components/sso.component.ts | 2 +- src/electron/window.main.ts | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/angular/components/sso.component.ts b/src/angular/components/sso.component.ts index f2f4db3bf8..9c537e8814 100644 --- a/src/angular/components/sso.component.ts +++ b/src/angular/components/sso.component.ts @@ -82,10 +82,10 @@ export class SsoComponent { const codeVerifierHash = await this.cryptoFunctionService.hash(codeVerifier, 'sha256'); codeChallenge = Utils.fromBufferToUrlB64(codeVerifierHash); await this.storageService.save(ConstantsService.ssoCodeVerifierKey, codeVerifier); - await this.storageService.save(ConstantsService.ssoStateKey, state); } if (state == null) { state = await this.passwordGenerationService.generatePassword(passwordOptions); + await this.storageService.save(ConstantsService.ssoStateKey, state); } const authorizeUrl = this.apiService.identityBaseUrl + '/connect/authorize?' + diff --git a/src/electron/window.main.ts b/src/electron/window.main.ts index c5d428d77f..bf4d28dbbb 100644 --- a/src/electron/window.main.ts +++ b/src/electron/window.main.ts @@ -22,7 +22,8 @@ export class WindowMain { private enableAlwaysOnTop: boolean = false; constructor(private storageService: StorageService, private hideTitleBar = false, - private defaultWidth = 950, private defaultHeight = 600) { } + private defaultWidth = 950, private defaultHeight = 600, + private argvCallback: (argv: string[]) => void = null) { } init(): Promise { return new Promise((resolve, reject) => { @@ -33,7 +34,7 @@ export class WindowMain { app.quit(); return; } else { - app.on('second-instance', (event, commandLine, workingDirectory) => { + app.on('second-instance', (event, argv, workingDirectory) => { // Someone tried to run a second instance, we should focus our window. if (this.win != null) { if (this.win.isMinimized() || !this.win.isVisible()) { @@ -41,6 +42,11 @@ export class WindowMain { } this.win.focus(); } + if (process.platform === 'win32' || process.platform === 'linux') { + if (this.argvCallback != null) { + this.argvCallback(argv); + } + } }); } } @@ -57,6 +63,9 @@ export class WindowMain { app.on('ready', async () => { await this.createWindow(); resolve(); + if (this.argvCallback != null) { + this.argvCallback(process.argv); + } }); // Quit when all windows are closed.