diff --git a/jslib b/jslib index 2192d071..d20f4631 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 2192d071bd703751ef3e3d9fa08210b8a937c002 +Subproject commit d20f46312c5ffce6f69e4b5cda7d4d384da262a3 diff --git a/src/app/accounts/settings.component.ts b/src/app/accounts/settings.component.ts index 76bdd8cc..9cdffce9 100644 --- a/src/app/accounts/settings.component.ts +++ b/src/app/accounts/settings.component.ts @@ -121,8 +121,8 @@ export class SettingsComponent implements OnInit { this.locale = await this.storageService.get(ConstantsService.localeKey); this.theme = await this.storageService.get(ConstantsService.themeKey); this.clearClipboard = await this.storageService.get(ConstantsService.clearClipboardKey); - this.minimizeOnCopyToClipboard = - await this.storageService.get(ElectronConstants.minimizeOnCopyToClipboardKey); + this.minimizeOnCopyToClipboard = await this.storageService.get( + ElectronConstants.minimizeOnCopyToClipboardKey); } async saveLockOption() { diff --git a/src/app/vault/vault.component.ts b/src/app/vault/vault.component.ts index a81036dc..dc3c584c 100644 --- a/src/app/vault/vault.component.ts +++ b/src/app/vault/vault.component.ts @@ -46,12 +46,15 @@ import { MessagingService } from 'jslib/abstractions/messaging.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { SyncService } from 'jslib/abstractions/sync.service'; +import { WindowMain } from '../../main/window.main'; + const SyncInterval = 6 * 60 * 60 * 1000; // 6 hours const BroadcasterSubscriptionId = 'VaultComponent'; @Component({ selector: 'app-vault', templateUrl: 'vault.component.html', + providers: [ WindowMain ], }) export class VaultComponent implements OnInit, OnDestroy { @ViewChild(ViewComponent) viewComponent: ViewComponent; @@ -84,7 +87,8 @@ export class VaultComponent implements OnInit, OnDestroy { private broadcasterService: BroadcasterService, private changeDetectorRef: ChangeDetectorRef, private ngZone: NgZone, private syncService: SyncService, private analytics: Angulartics2, private toasterService: ToasterService, private messagingService: MessagingService, - private platformUtilsService: PlatformUtilsService, private eventService: EventService) { } + private platformUtilsService: PlatformUtilsService, private eventService: EventService, + private windowMain: WindowMain) { } async ngOnInit() { this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => { @@ -660,7 +664,7 @@ 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(); + this.windowMain.minimizeIfNeeded(); }); } diff --git a/src/app/vault/view.component.ts b/src/app/vault/view.component.ts index f9720490..560c9006 100644 --- a/src/app/vault/view.component.ts +++ b/src/app/vault/view.component.ts @@ -7,16 +7,12 @@ import { Output, } from '@angular/core'; -import { EventType } from 'jslib/enums/eventType'; - import { AuditService } from 'jslib/abstractions/audit.service'; 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'; @@ -27,11 +23,12 @@ import { ViewComponent as BaseViewComponent } from 'jslib/angular/components/vie import { CipherView } from 'jslib/models/view/cipherView'; -import { ElectronConstants } from 'jslib/electron/electronConstants'; +import { WindowMain } from '../../main/window.main'; @Component({ selector: 'app-vault-view', templateUrl: 'view.component.html', + providers: [ WindowMain ], }) export class ViewComponent extends BaseViewComponent implements OnChanges { @Output() onViewCipherPasswordHistory = new EventEmitter(); @@ -42,7 +39,7 @@ export class ViewComponent extends BaseViewComponent implements OnChanges { auditService: AuditService, broadcasterService: BroadcasterService, ngZone: NgZone, changeDetectorRef: ChangeDetectorRef, userService: UserService, eventService: EventService, - protected messagingService: MessagingService, protected storageService: StorageService) { + private windowMain: WindowMain) { super(cipherService, totpService, tokenService, i18nService, cryptoService, platformUtilsService, auditService, window, broadcasterService, ngZone, changeDetectorRef, userService, eventService); } @@ -58,14 +55,6 @@ export class ViewComponent extends BaseViewComponent implements OnChanges { copy(value: string, typeI18nKey: string, aType: string) { super.copy(value, typeI18nKey, aType); - this.minimizeIfNeeded(); - } - - public async minimizeIfNeeded(): Promise { - const shouldMinimize = - await this.storageService.get(ElectronConstants.minimizeOnCopyToClipboardKey); - if (shouldMinimize) { - this.messagingService.send('minimize'); - } + this.windowMain.minimizeIfNeeded(); } } diff --git a/src/locales/en_GB/messages.json b/src/locales/en_GB/messages.json index 1289ee8f..ad3694cf 100644 --- a/src/locales/en_GB/messages.json +++ b/src/locales/en_GB/messages.json @@ -112,12 +112,6 @@ "message": "Copy value", "description": "Copy value to clipboard" }, - "minimizeOnCopyToClipboard": { - "message": "Minimize when copying to clipboard" - }, - "minimizeOnCopyToClipboardDesc": { - "message": "Bitwarden will minimize when credentials are copied to clipboard." - }, "toggleVisibility": { "message": "Toggle visibility" }, @@ -1286,4 +1280,4 @@ "passwordGeneratorPolicyInEffect": { "message": "One or more organisation policies are affecting your generator settings." } -} +} \ No newline at end of file diff --git a/src/main/window.main.ts b/src/main/window.main.ts new file mode 100644 index 00000000..dd10c1c0 --- /dev/null +++ b/src/main/window.main.ts @@ -0,0 +1,21 @@ +import { ElectronConstants } from 'jslib/electron/electronConstants'; + +import { MessagingService } from 'jslib/abstractions/messaging.service'; +import { StorageService } from 'jslib/abstractions/storage.service'; + +import { WindowMain as BaseWindowMain } from 'jslib/electron/window.main'; + +export class WindowMain extends BaseWindowMain { + + constructor(storageService: StorageService, private messagingService: MessagingService) { + super(storageService); + } + + async minimizeIfNeeded(): Promise { + const shouldMinimize = await this.storageService.get( + ElectronConstants.minimizeOnCopyToClipboardKey); + if (shouldMinimize) { + this.messagingService.send('minimize'); + } + } +}