1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-27 12:36:14 +01:00

Hide hidden fields on hide/minimize

This commit is contained in:
Chad Scharf 2020-11-04 12:09:21 -05:00
parent 4a18a4eb93
commit c001a00f82
9 changed files with 204 additions and 14 deletions

2
jslib

@ -1 +1 @@
Subproject commit 0e9e73ce95a321ee05edbb62c50f9e1828f69c5a Subproject commit 1beb30d11193bcb2e57fbdb8a147ddcb0c0ddbc2

View File

@ -1,4 +1,7 @@
import { Component } from '@angular/core'; import {
Component,
NgZone,
} from '@angular/core';
import { import {
ActivatedRoute, ActivatedRoute,
Router, Router,
@ -15,8 +18,12 @@ import { StorageService } from 'jslib/abstractions/storage.service';
import { UserService } from 'jslib/abstractions/user.service'; import { UserService } from 'jslib/abstractions/user.service';
import { VaultTimeoutService } from 'jslib/abstractions/vaultTimeout.service'; import { VaultTimeoutService } from 'jslib/abstractions/vaultTimeout.service';
import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';
import { LockComponent as BaseLockComponent } from 'jslib/angular/components/lock.component'; import { LockComponent as BaseLockComponent } from 'jslib/angular/components/lock.component';
const BroadcasterSubscriptionId = 'LockComponent';
@Component({ @Component({
selector: 'app-lock', selector: 'app-lock',
templateUrl: 'lock.component.html', templateUrl: 'lock.component.html',
@ -27,7 +34,8 @@ export class LockComponent extends BaseLockComponent {
userService: UserService, cryptoService: CryptoService, userService: UserService, cryptoService: CryptoService,
storageService: StorageService, vaultTimeoutService: VaultTimeoutService, storageService: StorageService, vaultTimeoutService: VaultTimeoutService,
environmentService: EnvironmentService, stateService: StateService, environmentService: EnvironmentService, stateService: StateService,
apiService: ApiService, private route: ActivatedRoute) { apiService: ApiService, private route: ActivatedRoute,
private broadcasterService: BroadcasterService, private ngZone: NgZone) {
super(router, i18nService, platformUtilsService, messagingService, userService, cryptoService, super(router, i18nService, platformUtilsService, messagingService, userService, cryptoService,
storageService, vaultTimeoutService, environmentService, stateService, apiService); storageService, vaultTimeoutService, environmentService, stateService, apiService);
} }
@ -39,5 +47,20 @@ export class LockComponent extends BaseLockComponent {
setTimeout(() => this.unlockBiometric(), 1000); setTimeout(() => this.unlockBiometric(), 1000);
} }
}); });
this.broadcasterService.subscribe(BroadcasterSubscriptionId, async (message: any) => {
this.ngZone.run(() => {
switch (message.command) {
case 'windowHidden':
this.onWindowHidden();
break;
default:
}
});
});
}
onWindowHidden() {
this.showPassword = false;
} }
} }

View File

@ -1,6 +1,7 @@
import { import {
Component, Component,
ComponentFactoryResolver, ComponentFactoryResolver,
NgZone,
ViewChild, ViewChild,
ViewContainerRef, ViewContainerRef,
} from '@angular/core'; } from '@angular/core';
@ -19,9 +20,13 @@ import { StateService } from 'jslib/abstractions/state.service';
import { StorageService } from 'jslib/abstractions/storage.service'; import { StorageService } from 'jslib/abstractions/storage.service';
import { SyncService } from 'jslib/abstractions/sync.service'; import { SyncService } from 'jslib/abstractions/sync.service';
import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';
import { LoginComponent as BaseLoginComponent } from 'jslib/angular/components/login.component'; import { LoginComponent as BaseLoginComponent } from 'jslib/angular/components/login.component';
import { ModalComponent } from 'jslib/angular/components/modal.component'; import { ModalComponent } from 'jslib/angular/components/modal.component';
const BroadcasterSubscriptionId = 'LoginComponent';
@Component({ @Component({
selector: 'app-login', selector: 'app-login',
templateUrl: 'login.component.html', templateUrl: 'login.component.html',
@ -35,7 +40,8 @@ export class LoginComponent extends BaseLoginComponent {
syncService: SyncService, private componentFactoryResolver: ComponentFactoryResolver, syncService: SyncService, private componentFactoryResolver: ComponentFactoryResolver,
platformUtilsService: PlatformUtilsService, stateService: StateService, platformUtilsService: PlatformUtilsService, stateService: StateService,
environmentService: EnvironmentService, passwordGenerationService: PasswordGenerationService, environmentService: EnvironmentService, passwordGenerationService: PasswordGenerationService,
cryptoFunctionService: CryptoFunctionService, storageService: StorageService) { cryptoFunctionService: CryptoFunctionService, storageService: StorageService,
private broadcasterService: BroadcasterService, private ngZone: NgZone) {
super(authService, router, platformUtilsService, i18nService, stateService, environmentService, super(authService, router, platformUtilsService, i18nService, stateService, environmentService,
passwordGenerationService, cryptoFunctionService, storageService); passwordGenerationService, cryptoFunctionService, storageService);
super.onSuccessfulLogin = () => { super.onSuccessfulLogin = () => {
@ -43,6 +49,21 @@ export class LoginComponent extends BaseLoginComponent {
}; };
} }
async ngOnInit() {
await super.ngOnInit();
this.broadcasterService.subscribe(BroadcasterSubscriptionId, async (message: any) => {
this.ngZone.run(() => {
switch (message.command) {
case 'windowHidden':
this.onWindowHidden();
break;
default:
}
});
});
}
settings() { settings() {
const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent); const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent);
const modal = this.environmentModal.createComponent(factory).instance; const modal = this.environmentModal.createComponent(factory).instance;
@ -61,4 +82,8 @@ export class LoginComponent extends BaseLoginComponent {
modal.close(); modal.close();
}); });
} }
onWindowHidden() {
this.showPassword = false;
}
} }

View File

@ -1,4 +1,8 @@
import { Component } from '@angular/core'; import {
Component,
OnInit,
NgZone,
} from '@angular/core';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { ApiService } from 'jslib/abstractions/api.service'; import { ApiService } from 'jslib/abstractions/api.service';
@ -9,18 +13,41 @@ import { PasswordGenerationService } from 'jslib/abstractions/passwordGeneration
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { StateService } from 'jslib/abstractions/state.service'; import { StateService } from 'jslib/abstractions/state.service';
import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';
import { RegisterComponent as BaseRegisterComponent } from 'jslib/angular/components/register.component'; import { RegisterComponent as BaseRegisterComponent } from 'jslib/angular/components/register.component';
const BroadcasterSubscriptionId = 'RegisterComponent';
@Component({ @Component({
selector: 'app-register', selector: 'app-register',
templateUrl: 'register.component.html', templateUrl: 'register.component.html',
}) })
export class RegisterComponent extends BaseRegisterComponent { export class RegisterComponent extends BaseRegisterComponent implements OnInit {
constructor(authService: AuthService, router: Router, constructor(authService: AuthService, router: Router,
i18nService: I18nService, cryptoService: CryptoService, i18nService: I18nService, cryptoService: CryptoService,
apiService: ApiService, stateService: StateService, apiService: ApiService, stateService: StateService,
platformUtilsService: PlatformUtilsService, passwordGenerationService: PasswordGenerationService) { platformUtilsService: PlatformUtilsService, passwordGenerationService: PasswordGenerationService,
private broadcasterService: BroadcasterService, private ngZone: NgZone) {
super(authService, router, i18nService, cryptoService, apiService, stateService, platformUtilsService, super(authService, router, i18nService, cryptoService, apiService, stateService, platformUtilsService,
passwordGenerationService); passwordGenerationService);
} }
async ngOnInit() {
this.broadcasterService.subscribe(BroadcasterSubscriptionId, async (message: any) => {
this.ngZone.run(() => {
switch (message.command) {
case 'windowHidden':
this.onWindowHidden();
break;
default:
}
});
});
}
onWindowHidden() {
this.showPassword = false;
}
} }

View File

@ -1,4 +1,7 @@
import { Component } from '@angular/core'; import {
Component,
NgZone,
} from '@angular/core';
import { import {
ActivatedRoute, ActivatedRoute,
@ -15,6 +18,10 @@ import { PolicyService } from 'jslib/abstractions/policy.service';
import { SyncService } from 'jslib/abstractions/sync.service'; import { SyncService } from 'jslib/abstractions/sync.service';
import { UserService } from 'jslib/abstractions/user.service'; import { UserService } from 'jslib/abstractions/user.service';
import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';
const BroadcasterSubscriptionId = 'SetPasswordComponent';
import { import {
SetPasswordComponent as BaseSetPasswordComponent, SetPasswordComponent as BaseSetPasswordComponent,
} from 'jslib/angular/components/set-password.component'; } from 'jslib/angular/components/set-password.component';
@ -28,7 +35,8 @@ export class SetPasswordComponent extends BaseSetPasswordComponent {
cryptoService: CryptoService, messagingService: MessagingService, cryptoService: CryptoService, messagingService: MessagingService,
userService: UserService, passwordGenerationService: PasswordGenerationService, userService: UserService, passwordGenerationService: PasswordGenerationService,
platformUtilsService: PlatformUtilsService, policyService: PolicyService, router: Router, platformUtilsService: PlatformUtilsService, policyService: PolicyService, router: Router,
syncService: SyncService, route: ActivatedRoute) { syncService: SyncService, route: ActivatedRoute,
private broadcasterService: BroadcasterService, private ngZone: NgZone) {
super(i18nService, cryptoService, messagingService, userService, passwordGenerationService, super(i18nService, cryptoService, messagingService, userService, passwordGenerationService,
platformUtilsService, policyService, router, apiService, syncService, route); platformUtilsService, policyService, router, apiService, syncService, route);
} }
@ -62,4 +70,23 @@ export class SetPasswordComponent extends BaseSetPasswordComponent {
return this.masterPasswordScore != null ? this.i18nService.t('weak') : null; return this.masterPasswordScore != null ? this.i18nService.t('weak') : null;
} }
} }
async ngOnInit() {
await super.ngOnInit();
this.broadcasterService.subscribe(BroadcasterSubscriptionId, async (message: any) => {
this.ngZone.run(() => {
switch (message.command) {
case 'windowHidden':
this.onWindowHidden();
break;
default:
}
});
});
}
onWindowHidden() {
this.showPassword = false;
}
} }

View File

@ -1,6 +1,7 @@
import { import {
Component, Component,
OnChanges, OnChanges,
NgZone,
} from '@angular/core'; } from '@angular/core';
import { AuditService } from 'jslib/abstractions/audit.service'; import { AuditService } from 'jslib/abstractions/audit.service';
@ -14,8 +15,12 @@ import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { StateService } from 'jslib/abstractions/state.service'; import { StateService } from 'jslib/abstractions/state.service';
import { UserService } from 'jslib/abstractions/user.service'; import { UserService } from 'jslib/abstractions/user.service';
import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';
import { AddEditComponent as BaseAddEditComponent } from 'jslib/angular/components/add-edit.component'; import { AddEditComponent as BaseAddEditComponent } from 'jslib/angular/components/add-edit.component';
const BroadcasterSubscriptionId = 'AddEditComponent';
@Component({ @Component({
selector: 'app-vault-add-edit', selector: 'app-vault-add-edit',
templateUrl: 'add-edit.component.html', templateUrl: 'add-edit.component.html',
@ -25,13 +30,25 @@ export class AddEditComponent extends BaseAddEditComponent implements OnChanges
i18nService: I18nService, platformUtilsService: PlatformUtilsService, i18nService: I18nService, platformUtilsService: PlatformUtilsService,
auditService: AuditService, stateService: StateService, auditService: AuditService, stateService: StateService,
userService: UserService, collectionService: CollectionService, userService: UserService, collectionService: CollectionService,
messagingService: MessagingService, eventService: EventService) { messagingService: MessagingService, eventService: EventService,
private broadcasterService: BroadcasterService, private ngZone: NgZone) {
super(cipherService, folderService, i18nService, platformUtilsService, auditService, stateService, super(cipherService, folderService, i18nService, platformUtilsService, auditService, stateService,
userService, collectionService, messagingService, eventService); userService, collectionService, messagingService, eventService);
} }
async ngOnInit() { async ngOnInit() {
// We use ngOnChanges instead. this.broadcasterService.subscribe(BroadcasterSubscriptionId, async (message: any) => {
this.ngZone.run(() => {
switch (message.command) {
case 'windowHidden':
this.onWindowHidden();
break;
default:
}
});
});
// We use ngOnChanges for everything else instead.
} }
async ngOnChanges() { async ngOnChanges() {
@ -46,4 +63,14 @@ export class AddEditComponent extends BaseAddEditComponent implements OnChanges
} }
super.load(); super.load();
} }
onWindowHidden() {
this.showPassword = false;
this.showCardCode = false;
if (this.cipher !== null && this.cipher.hasFields) {
this.cipher.fields.forEach(field => {
field.showValue = false;
});
}
}
} }

View File

@ -1,4 +1,8 @@
import { Component } from '@angular/core'; import {
Component,
OnInit,
NgZone,
} from '@angular/core';
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';
@ -6,16 +10,39 @@ import { ExportService } from 'jslib/abstractions/export.service';
import { I18nService } from 'jslib/abstractions/i18n.service'; import { I18nService } from 'jslib/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';
import { ExportComponent as BaseExportComponent } from 'jslib/angular/components/export.component'; import { ExportComponent as BaseExportComponent } from 'jslib/angular/components/export.component';
const BroadcasterSubscriptionId = 'ExportComponent';
@Component({ @Component({
selector: 'app-export', selector: 'app-export',
templateUrl: 'export.component.html', templateUrl: 'export.component.html',
}) })
export class ExportComponent extends BaseExportComponent { export class ExportComponent extends BaseExportComponent implements OnInit {
constructor(cryptoService: CryptoService, i18nService: I18nService, constructor(cryptoService: CryptoService, i18nService: I18nService,
platformUtilsService: PlatformUtilsService, exportService: ExportService, platformUtilsService: PlatformUtilsService, exportService: ExportService,
eventService: EventService) { eventService: EventService, private broadcasterService: BroadcasterService,
private ngZone: NgZone) {
super(cryptoService, i18nService, platformUtilsService, exportService, eventService, window); super(cryptoService, i18nService, platformUtilsService, exportService, eventService, window);
} }
async ngOnInit() {
this.broadcasterService.subscribe(BroadcasterSubscriptionId, async (message: any) => {
this.ngZone.run(() => {
switch (message.command) {
case 'windowHidden':
this.onWindowHidden();
break;
default:
}
});
});
}
onWindowHidden() {
this.showPassword = false;
}
} }

View File

@ -25,6 +25,8 @@ import { ViewComponent as BaseViewComponent } from 'jslib/angular/components/vie
import { CipherView } from 'jslib/models/view/cipherView'; import { CipherView } from 'jslib/models/view/cipherView';
const BroadcasterSubscriptionId = 'ViewComponent';
@Component({ @Component({
selector: 'app-vault-view', selector: 'app-vault-view',
templateUrl: 'view.component.html', templateUrl: 'view.component.html',
@ -42,6 +44,20 @@ export class ViewComponent extends BaseViewComponent implements OnChanges {
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);
} }
ngOnInit() {
super.ngOnInit();
this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => {
this.ngZone.run(() => {
switch (message.command) {
case 'windowHidden':
this.onWindowHidden();
break;
default:
}
});
});
}
async ngOnChanges() { async ngOnChanges() {
await super.load(); await super.load();
@ -56,4 +72,14 @@ export class ViewComponent extends BaseViewComponent implements OnChanges {
super.copy(value, typeI18nKey, aType); super.copy(value, typeI18nKey, aType);
this.messagingService.send('minimizeOnCopy'); this.messagingService.send('minimizeOnCopy');
} }
onWindowHidden() {
this.showPassword = false;
this.showCardCode = false;
if (this.cipher !== null && this.cipher.hasFields) {
this.cipher.fields.forEach(field => {
field.showValue = false;
});
}
}
} }

View File

@ -149,6 +149,14 @@ export class Main {
event.preventDefault(); event.preventDefault();
this.processDeepLink([url]); this.processDeepLink([url]);
}); });
// Handle window visibility events
this.windowMain.win.on('hide', () => {
this.messagingService.send('windowHidden');
});
this.windowMain.win.on('minimize', () => {
this.messagingService.send('windowHidden');
});
}, (e: any) => { }, (e: any) => {
// tslint:disable-next-line // tslint:disable-next-line
console.error(e); console.error(e);