1
0
mirror of https://github.com/bitwarden/desktop.git synced 2024-09-27 03:53:00 +02: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
No known key found for this signature in database
GPG Key ID: B3E61DBEDF649349
6 changed files with 35 additions and 27 deletions

2
jslib

@ -1 +1 @@
Subproject commit 2192d071bd703751ef3e3d9fa08210b8a937c002
Subproject commit d20f46312c5ffce6f69e4b5cda7d4d384da262a3

View File

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

View File

@ -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();
});
}

View File

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

View File

@ -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."
}
}
}

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');
}
}
}