From ebda0bd23f8fc39f1f55910cb958fb30432e559c Mon Sep 17 00:00:00 2001 From: Elias Papavasileiou Date: Wed, 26 Feb 2020 02:30:33 +0200 Subject: [PATCH] Add minimizeIfNeeded method to view component --- src/angular/components/view.component.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/angular/components/view.component.ts b/src/angular/components/view.component.ts index a0d60764..995f8cfc 100644 --- a/src/angular/components/view.component.ts +++ b/src/angular/components/view.component.ts @@ -17,7 +17,9 @@ import { CipherService } from '../../abstractions/cipher.service'; import { CryptoService } from '../../abstractions/crypto.service'; import { EventService } from '../../abstractions/event.service'; import { I18nService } from '../../abstractions/i18n.service'; +import { MessagingService } from '../../abstractions/messaging.service'; import { PlatformUtilsService } from '../../abstractions/platformUtils.service'; +import { StorageService } from '../../abstractions/storage.service'; import { TokenService } from '../../abstractions/token.service'; import { TotpService } from '../../abstractions/totp.service'; import { UserService } from '../../abstractions/user.service'; @@ -28,6 +30,8 @@ import { FieldView } from '../../models/view/fieldView'; import { LoginUriView } from '../../models/view/loginUriView'; import { BroadcasterService } from '../services/broadcaster.service'; +import { ElectronConstants } from '../../electron/electronConstants'; + const BroadcasterSubscriptionId = 'ViewComponent'; export class ViewComponent implements OnDestroy, OnInit { @@ -56,7 +60,8 @@ export class ViewComponent implements OnDestroy, OnInit { protected auditService: AuditService, protected win: Window, protected broadcasterService: BroadcasterService, protected ngZone: NgZone, protected changeDetectorRef: ChangeDetectorRef, protected userService: UserService, - protected eventService: EventService) { } + protected eventService: EventService, protected messagingService: MessagingService, + protected storageService: StorageService) { } ngOnInit() { this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => { @@ -170,6 +175,7 @@ export class ViewComponent implements OnDestroy, OnInit { this.platformUtilsService.copyToClipboard(value, copyOptions); this.platformUtilsService.showToast('info', null, this.i18nService.t('valueCopied', this.i18nService.t(typeI18nKey))); + this.minimizeIfNeeded(); if (typeI18nKey === 'password') { this.eventService.collect(EventType.Cipher_ClientToggledHiddenFieldVisible, this.cipherId); @@ -184,6 +190,14 @@ export class ViewComponent implements OnDestroy, OnInit { event.dataTransfer.setData('text', data); } + public async minimizeIfNeeded(): Promise { + const shouldMinimize = + await this.storageService.get(ElectronConstants.minimizeOnCopyToClipboardKey); + if (shouldMinimize) { + this.messagingService.send('minimize'); + } + } + async downloadAttachment(attachment: AttachmentView) { const a = (attachment as any); if (a.downloading) {