Restore focus when displaying sync confirm

This commit is contained in:
Hinton 2020-11-30 14:58:52 +01:00
parent 7da03dc91c
commit ed0acdead2
4 changed files with 20 additions and 6 deletions

View File

@ -133,7 +133,8 @@ const environmentService = new EnvironmentService(apiService, storageService, no
const eventService = new EventService(storageService, apiService, userService, cipherService); const eventService = new EventService(storageService, apiService, userService, cipherService);
const systemService = new SystemService(storageService, vaultTimeoutService, messagingService, platformUtilsService, const systemService = new SystemService(storageService, vaultTimeoutService, messagingService, platformUtilsService,
null); null);
const nativeMessagingService = new NativeMessagingService(cryptoFunctionService, cryptoService, platformUtilsService, logService, i18nService, userService); const nativeMessagingService = new NativeMessagingService(cryptoFunctionService, cryptoService, platformUtilsService,
logService, i18nService, userService, messagingService);
const analytics = new Analytics(window, () => isDev(), platformUtilsService, storageService, appIdService); const analytics = new Analytics(window, () => isDev(), platformUtilsService, storageService, appIdService);
containerService.attachToGlobal(window); containerService.attachToGlobal(window);

View File

@ -44,6 +44,9 @@ export class MessagingMain {
case 'hideToTray': case 'hideToTray':
this.main.trayMain.hideToTray(); this.main.trayMain.hideToTray();
break; break;
case 'setFocus':
this.setFocus();
break;
case 'enableBrowserIntegration': case 'enableBrowserIntegration':
this.main.nativeMessagingMain.generateManifests(); this.main.nativeMessagingMain.generateManifests();
this.main.nativeMessagingMain.listen(); this.main.nativeMessagingMain.listen();
@ -82,4 +85,9 @@ export class MessagingMain {
lockNowTrayMenuItem.enabled = isAuthenticated && !isLocked; lockNowTrayMenuItem.enabled = isAuthenticated && !isLocked;
} }
} }
private setFocus() {
this.main.trayMain.restoreFromTray();
this.main.windowMain.win.focusOnWebView();
}
} }

View File

@ -25,7 +25,7 @@ export class NativeMessagingMain {
if (msg != null) { if (msg != null) {
this.send(msg, socket); this.send(msg, socket);
} }
}) });
}); });
ipc.server.on('connect', () => { ipc.server.on('connect', () => {

View File

@ -3,12 +3,14 @@ import Swal from 'sweetalert2';
import { CryptoService } from 'jslib/abstractions/crypto.service'; import { CryptoService } from 'jslib/abstractions/crypto.service';
import { CryptoFunctionService } from 'jslib/abstractions/cryptoFunction.service'; import { CryptoFunctionService } from 'jslib/abstractions/cryptoFunction.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { I18nService } from 'jslib/abstractions/i18n.service';
import { LogService } from 'jslib/abstractions/log.service'; import { LogService } from 'jslib/abstractions/log.service';
import { MessagingService } from 'jslib/abstractions/messaging.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { UserService } from 'jslib/abstractions/user.service';
import { Utils } from 'jslib/misc/utils'; import { Utils } from 'jslib/misc/utils';
import { SymmetricCryptoKey } from 'jslib/models/domain/symmetricCryptoKey'; import { SymmetricCryptoKey } from 'jslib/models/domain/symmetricCryptoKey';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { UserService } from 'jslib/abstractions/user.service';
const MessageValidTimeout = 10 * 1000; const MessageValidTimeout = 10 * 1000;
const EncryptionAlgorithm = 'sha1'; const EncryptionAlgorithm = 'sha1';
@ -17,7 +19,8 @@ export class NativeMessagingService {
private sharedSecret: any; private sharedSecret: any;
constructor(private cryptoFunctionService: CryptoFunctionService, private cryptoService: CryptoService, constructor(private cryptoFunctionService: CryptoFunctionService, private cryptoService: CryptoService,
private platformUtilService: PlatformUtilsService, private logService: LogService, private i18nService: I18nService, private userService: UserService) { private platformUtilService: PlatformUtilsService, private logService: LogService, private i18nService: I18nService,
private userService: UserService, private messagingService: MessagingService) {
ipcRenderer.on('nativeMessaging', async (event: any, message: any) => { ipcRenderer.on('nativeMessaging', async (event: any, message: any) => {
this.messageHandler(message); this.messageHandler(message);
}); });
@ -30,6 +33,8 @@ export class NativeMessagingService {
const remotePublicKey = Utils.fromB64ToArray(rawMessage.publicKey).buffer; const remotePublicKey = Utils.fromB64ToArray(rawMessage.publicKey).buffer;
const fingerprint = (await this.cryptoService.getFingerprint(await this.userService.getUserId(), remotePublicKey)).join(' '); const fingerprint = (await this.cryptoService.getFingerprint(await this.userService.getUserId(), remotePublicKey)).join(' ');
this.messagingService.send('setFocus');
// Await confirmation that fingerprint is correct // Await confirmation that fingerprint is correct
const submitted = await Swal.fire({ const submitted = await Swal.fire({
title: this.i18nService.t('verifyBrowserTitle'), title: this.i18nService.t('verifyBrowserTitle'),