1
0
mirror of https://github.com/bitwarden/jslib synced 2025-12-21 02:33:37 +00:00

Add minimizeIfNeeded method to view component

This commit is contained in:
Elias Papavasileiou
2020-02-26 02:30:33 +02:00
parent e4c94ce79b
commit ebda0bd23f

View File

@@ -17,7 +17,9 @@ import { CipherService } from '../../abstractions/cipher.service';
import { CryptoService } from '../../abstractions/crypto.service'; import { CryptoService } from '../../abstractions/crypto.service';
import { EventService } from '../../abstractions/event.service'; import { EventService } from '../../abstractions/event.service';
import { I18nService } from '../../abstractions/i18n.service'; import { I18nService } from '../../abstractions/i18n.service';
import { MessagingService } from '../../abstractions/messaging.service';
import { PlatformUtilsService } from '../../abstractions/platformUtils.service'; import { PlatformUtilsService } from '../../abstractions/platformUtils.service';
import { StorageService } from '../../abstractions/storage.service';
import { TokenService } from '../../abstractions/token.service'; import { TokenService } from '../../abstractions/token.service';
import { TotpService } from '../../abstractions/totp.service'; import { TotpService } from '../../abstractions/totp.service';
import { UserService } from '../../abstractions/user.service'; import { UserService } from '../../abstractions/user.service';
@@ -28,6 +30,8 @@ import { FieldView } from '../../models/view/fieldView';
import { LoginUriView } from '../../models/view/loginUriView'; import { LoginUriView } from '../../models/view/loginUriView';
import { BroadcasterService } from '../services/broadcaster.service'; import { BroadcasterService } from '../services/broadcaster.service';
import { ElectronConstants } from '../../electron/electronConstants';
const BroadcasterSubscriptionId = 'ViewComponent'; const BroadcasterSubscriptionId = 'ViewComponent';
export class ViewComponent implements OnDestroy, OnInit { export class ViewComponent implements OnDestroy, OnInit {
@@ -56,7 +60,8 @@ export class ViewComponent implements OnDestroy, OnInit {
protected auditService: AuditService, protected win: Window, protected auditService: AuditService, protected win: Window,
protected broadcasterService: BroadcasterService, protected ngZone: NgZone, protected broadcasterService: BroadcasterService, protected ngZone: NgZone,
protected changeDetectorRef: ChangeDetectorRef, protected userService: UserService, protected changeDetectorRef: ChangeDetectorRef, protected userService: UserService,
protected eventService: EventService) { } protected eventService: EventService, protected messagingService: MessagingService,
protected storageService: StorageService) { }
ngOnInit() { ngOnInit() {
this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => { this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => {
@@ -170,6 +175,7 @@ export class ViewComponent implements OnDestroy, OnInit {
this.platformUtilsService.copyToClipboard(value, copyOptions); this.platformUtilsService.copyToClipboard(value, copyOptions);
this.platformUtilsService.showToast('info', null, this.platformUtilsService.showToast('info', null,
this.i18nService.t('valueCopied', this.i18nService.t(typeI18nKey))); this.i18nService.t('valueCopied', this.i18nService.t(typeI18nKey)));
this.minimizeIfNeeded();
if (typeI18nKey === 'password') { if (typeI18nKey === 'password') {
this.eventService.collect(EventType.Cipher_ClientToggledHiddenFieldVisible, this.cipherId); this.eventService.collect(EventType.Cipher_ClientToggledHiddenFieldVisible, this.cipherId);
@@ -184,6 +190,14 @@ export class ViewComponent implements OnDestroy, OnInit {
event.dataTransfer.setData('text', data); event.dataTransfer.setData('text', data);
} }
public async minimizeIfNeeded(): Promise<void> {
const shouldMinimize =
await this.storageService.get<boolean>(ElectronConstants.minimizeOnCopyToClipboardKey);
if (shouldMinimize) {
this.messagingService.send('minimize');
}
}
async downloadAttachment(attachment: AttachmentView) { async downloadAttachment(attachment: AttachmentView) {
const a = (attachment as any); const a = (attachment as any);
if (a.downloading) { if (a.downloading) {