callbacks for argv from window main (#141)

This commit is contained in:
Kyle Spearrin 2020-08-05 10:53:26 -04:00 committed by GitHub
parent 31a0be290b
commit 1513b25a35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -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?' +

View File

@ -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<any> {
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.