From 884939918472f4907ebe514cfb5cfc8504791cd9 Mon Sep 17 00:00:00 2001 From: Elias Papavasileiou Date: Wed, 26 Feb 2020 02:34:21 +0200 Subject: [PATCH] Extend feature to context menus and view component --- src/app/vault/vault.component.ts | 11 +---------- src/app/vault/view.component.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/app/vault/vault.component.ts b/src/app/vault/vault.component.ts index e9808488..b5361bb5 100644 --- a/src/app/vault/vault.component.ts +++ b/src/app/vault/vault.component.ts @@ -163,7 +163,6 @@ export class VaultComponent implements OnInit, OnDestroy { if (this.cipherId != null && uCipher != null && uCipher.id === this.cipherId && uCipher.login != null && uCipher.login.username != null) { this.copyValue(uCipher.login.username, 'username'); - this.minimizeIfNeeded(); } break; case 'copyPassword': @@ -172,7 +171,6 @@ export class VaultComponent implements OnInit, OnDestroy { if (this.cipherId != null && pCipher != null && pCipher.id === this.cipherId && pCipher.login != null && pCipher.login.password != null) { this.copyValue(pCipher.login.password, 'password'); - this.minimizeIfNeeded(); } break; default: @@ -666,17 +664,10 @@ export class VaultComponent implements OnInit, OnDestroy { this.platformUtilsService.copyToClipboard(value); this.toasterService.popAsync('info', null, this.i18nService.t('valueCopied', this.i18nService.t(labelI18nKey))); + this.viewComponent.minimizeIfNeeded(); }); } - private async minimizeIfNeeded(): Promise { - const shouldMinimize = - await this.storageService.get(ElectronConstants.minimizeOnCopyToClipboardKey); - if (shouldMinimize) { - this.messagingService.send('minimize'); - } - } - private functionWithChangeDetection(func: Function) { this.ngZone.run(() => { func(); diff --git a/src/app/vault/view.component.ts b/src/app/vault/view.component.ts index 9d0a840f..2a913c29 100644 --- a/src/app/vault/view.component.ts +++ b/src/app/vault/view.component.ts @@ -12,7 +12,9 @@ import { CipherService } from 'jslib/abstractions/cipher.service'; import { CryptoService } from 'jslib/abstractions/crypto.service'; import { EventService } from 'jslib/abstractions/event.service'; import { I18nService } from 'jslib/abstractions/i18n.service'; +import { MessagingService } from 'jslib/abstractions/messaging.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; +import { StorageService } from 'jslib/abstractions/storage.service'; import { TokenService } from 'jslib/abstractions/token.service'; import { TotpService } from 'jslib/abstractions/totp.service'; import { UserService } from 'jslib/abstractions/user.service'; @@ -35,9 +37,11 @@ export class ViewComponent extends BaseViewComponent implements OnChanges { cryptoService: CryptoService, platformUtilsService: PlatformUtilsService, auditService: AuditService, broadcasterService: BroadcasterService, ngZone: NgZone, changeDetectorRef: ChangeDetectorRef, - userService: UserService, eventService: EventService) { + userService: UserService, eventService: EventService, + messagingService: MessagingService, storageService: StorageService) { super(cipherService, totpService, tokenService, i18nService, cryptoService, platformUtilsService, - auditService, window, broadcasterService, ngZone, changeDetectorRef, userService, eventService); + auditService, window, broadcasterService, ngZone, changeDetectorRef, userService, eventService, + messagingService, storageService); } async ngOnChanges() {