1
0
mirror of https://github.com/bitwarden/desktop synced 2025-12-20 18:23:14 +00:00

Use window.main subclass and fix formatting

This commit is contained in:
Elias Papavasileiou
2020-03-16 03:00:13 +02:00
parent 46192c9ef9
commit 0159613751
6 changed files with 35 additions and 27 deletions

2
jslib

Submodule jslib updated: 2192d071bd...d20f46312c

View File

@@ -121,8 +121,8 @@ export class SettingsComponent implements OnInit {
this.locale = await this.storageService.get<string>(ConstantsService.localeKey); this.locale = await this.storageService.get<string>(ConstantsService.localeKey);
this.theme = await this.storageService.get<string>(ConstantsService.themeKey); this.theme = await this.storageService.get<string>(ConstantsService.themeKey);
this.clearClipboard = await this.storageService.get<number>(ConstantsService.clearClipboardKey); this.clearClipboard = await this.storageService.get<number>(ConstantsService.clearClipboardKey);
this.minimizeOnCopyToClipboard = this.minimizeOnCopyToClipboard = await this.storageService.get<boolean>(
await this.storageService.get<boolean>(ElectronConstants.minimizeOnCopyToClipboardKey); ElectronConstants.minimizeOnCopyToClipboardKey);
} }
async saveLockOption() { async saveLockOption() {

View File

@@ -46,12 +46,15 @@ import { MessagingService } from 'jslib/abstractions/messaging.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { SyncService } from 'jslib/abstractions/sync.service'; import { SyncService } from 'jslib/abstractions/sync.service';
import { WindowMain } from '../../main/window.main';
const SyncInterval = 6 * 60 * 60 * 1000; // 6 hours const SyncInterval = 6 * 60 * 60 * 1000; // 6 hours
const BroadcasterSubscriptionId = 'VaultComponent'; const BroadcasterSubscriptionId = 'VaultComponent';
@Component({ @Component({
selector: 'app-vault', selector: 'app-vault',
templateUrl: 'vault.component.html', templateUrl: 'vault.component.html',
providers: [ WindowMain ],
}) })
export class VaultComponent implements OnInit, OnDestroy { export class VaultComponent implements OnInit, OnDestroy {
@ViewChild(ViewComponent) viewComponent: ViewComponent; @ViewChild(ViewComponent) viewComponent: ViewComponent;
@@ -84,7 +87,8 @@ export class VaultComponent implements OnInit, OnDestroy {
private broadcasterService: BroadcasterService, private changeDetectorRef: ChangeDetectorRef, private broadcasterService: BroadcasterService, private changeDetectorRef: ChangeDetectorRef,
private ngZone: NgZone, private syncService: SyncService, private analytics: Angulartics2, private ngZone: NgZone, private syncService: SyncService, private analytics: Angulartics2,
private toasterService: ToasterService, private messagingService: MessagingService, private toasterService: ToasterService, private messagingService: MessagingService,
private platformUtilsService: PlatformUtilsService, private eventService: EventService) { } private platformUtilsService: PlatformUtilsService, private eventService: EventService,
private windowMain: WindowMain) { }
async ngOnInit() { async ngOnInit() {
this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => { this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => {
@@ -660,7 +664,7 @@ export class VaultComponent implements OnInit, OnDestroy {
this.platformUtilsService.copyToClipboard(value); this.platformUtilsService.copyToClipboard(value);
this.toasterService.popAsync('info', null, this.toasterService.popAsync('info', null,
this.i18nService.t('valueCopied', this.i18nService.t(labelI18nKey))); this.i18nService.t('valueCopied', this.i18nService.t(labelI18nKey)));
this.viewComponent.minimizeIfNeeded(); this.windowMain.minimizeIfNeeded();
}); });
} }

View File

@@ -7,16 +7,12 @@ import {
Output, Output,
} from '@angular/core'; } from '@angular/core';
import { EventType } from 'jslib/enums/eventType';
import { AuditService } from 'jslib/abstractions/audit.service'; import { AuditService } from 'jslib/abstractions/audit.service';
import { CipherService } from 'jslib/abstractions/cipher.service'; import { CipherService } from 'jslib/abstractions/cipher.service';
import { CryptoService } from 'jslib/abstractions/crypto.service'; import { CryptoService } from 'jslib/abstractions/crypto.service';
import { EventService } from 'jslib/abstractions/event.service'; import { EventService } from 'jslib/abstractions/event.service';
import { I18nService } from 'jslib/abstractions/i18n.service'; import { I18nService } from 'jslib/abstractions/i18n.service';
import { MessagingService } from 'jslib/abstractions/messaging.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { StorageService } from 'jslib/abstractions/storage.service';
import { TokenService } from 'jslib/abstractions/token.service'; import { TokenService } from 'jslib/abstractions/token.service';
import { TotpService } from 'jslib/abstractions/totp.service'; import { TotpService } from 'jslib/abstractions/totp.service';
import { UserService } from 'jslib/abstractions/user.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 { CipherView } from 'jslib/models/view/cipherView';
import { ElectronConstants } from 'jslib/electron/electronConstants'; import { WindowMain } from '../../main/window.main';
@Component({ @Component({
selector: 'app-vault-view', selector: 'app-vault-view',
templateUrl: 'view.component.html', templateUrl: 'view.component.html',
providers: [ WindowMain ],
}) })
export class ViewComponent extends BaseViewComponent implements OnChanges { export class ViewComponent extends BaseViewComponent implements OnChanges {
@Output() onViewCipherPasswordHistory = new EventEmitter<CipherView>(); @Output() onViewCipherPasswordHistory = new EventEmitter<CipherView>();
@@ -42,7 +39,7 @@ export class ViewComponent extends BaseViewComponent implements OnChanges {
auditService: AuditService, broadcasterService: BroadcasterService, auditService: AuditService, broadcasterService: BroadcasterService,
ngZone: NgZone, changeDetectorRef: ChangeDetectorRef, ngZone: NgZone, changeDetectorRef: ChangeDetectorRef,
userService: UserService, eventService: EventService, userService: UserService, eventService: EventService,
protected messagingService: MessagingService, protected storageService: StorageService) { private windowMain: WindowMain) {
super(cipherService, totpService, tokenService, i18nService, cryptoService, platformUtilsService, super(cipherService, totpService, tokenService, i18nService, cryptoService, platformUtilsService,
auditService, window, broadcasterService, ngZone, changeDetectorRef, userService, eventService); 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) { copy(value: string, typeI18nKey: string, aType: string) {
super.copy(value, typeI18nKey, aType); super.copy(value, typeI18nKey, aType);
this.minimizeIfNeeded(); this.windowMain.minimizeIfNeeded();
}
public async minimizeIfNeeded(): Promise<void> {
const shouldMinimize =
await this.storageService.get<boolean>(ElectronConstants.minimizeOnCopyToClipboardKey);
if (shouldMinimize) {
this.messagingService.send('minimize');
}
} }
} }

View File

@@ -112,12 +112,6 @@
"message": "Copy value", "message": "Copy value",
"description": "Copy value to clipboard" "description": "Copy value to clipboard"
}, },
"minimizeOnCopyToClipboard": {
"message": "Minimize when copying to clipboard"
},
"minimizeOnCopyToClipboardDesc": {
"message": "Bitwarden will minimize when credentials are copied to clipboard."
},
"toggleVisibility": { "toggleVisibility": {
"message": "Toggle visibility" "message": "Toggle visibility"
}, },

21
src/main/window.main.ts Normal file
View File

@@ -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<void> {
const shouldMinimize = await this.storageService.get<boolean>(
ElectronConstants.minimizeOnCopyToClipboardKey);
if (shouldMinimize) {
this.messagingService.send('minimize');
}
}
}