mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-26 17:08:33 +01:00
Refresh window when locked to enure that all purged memory is cleaned up
This commit is contained in:
parent
2ccbcb75bf
commit
24bd7208fd
2
jslib
2
jslib
@ -1 +1 @@
|
||||
Subproject commit cddeeefdbb14d5f70020fb705885eb05a0bb4339
|
||||
Subproject commit 7a3462afdabaab0b15b1a41b9b173d5efd23bb4a
|
@ -1,22 +1,72 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import {
|
||||
Component,
|
||||
NgZone,
|
||||
OnDestroy,
|
||||
OnInit,
|
||||
} from '@angular/core';
|
||||
import {
|
||||
ActivatedRoute,
|
||||
Router,
|
||||
} from '@angular/router';
|
||||
|
||||
import { CryptoService } from 'jslib/abstractions/crypto.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 { UserService } from 'jslib/abstractions/user.service';
|
||||
|
||||
import { ConstantsService } from 'jslib/services/constants.service';
|
||||
|
||||
import { LockComponent as BaseLockComponent } from 'jslib/angular/components/lock.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-lock',
|
||||
templateUrl: 'lock.component.html',
|
||||
})
|
||||
export class LockComponent extends BaseLockComponent {
|
||||
export class LockComponent extends BaseLockComponent implements OnInit, OnDestroy {
|
||||
private reloadInterval: number = null;
|
||||
|
||||
constructor(router: Router, i18nService: I18nService,
|
||||
platformUtilsService: PlatformUtilsService, messagingService: MessagingService,
|
||||
userService: UserService, cryptoService: CryptoService) {
|
||||
userService: UserService, cryptoService: CryptoService,
|
||||
private ngZone: NgZone, private route: ActivatedRoute,
|
||||
private storageService: StorageService) {
|
||||
super(router, i18nService, platformUtilsService, messagingService, userService, cryptoService);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.queryParams.subscribe((params) => {
|
||||
if (params.refresh === 'true') {
|
||||
// Refresh the renderer window when locked to enure that all purged memory is cleaned up
|
||||
this.ngZone.runOutsideAngular(() => {
|
||||
this.reloadInterval = window.setInterval(async () => {
|
||||
let doRefresh = false;
|
||||
const lastActive = await this.storageService.get<number>(ConstantsService.lastActiveKey);
|
||||
if (lastActive != null) {
|
||||
const diffSeconds = (new Date()).getTime() - lastActive;
|
||||
// Don't refresh if they are still active in the window
|
||||
doRefresh = diffSeconds >= 5000;
|
||||
}
|
||||
if (doRefresh) {
|
||||
window.clearInterval(this.reloadInterval);
|
||||
this.reloadInterval = null;
|
||||
window.location.reload(true);
|
||||
}
|
||||
}, 10000);
|
||||
});
|
||||
this.router.navigate([], {
|
||||
relativeTo: this.route,
|
||||
queryParams: {},
|
||||
replaceUrl: true,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.reloadInterval != null) {
|
||||
window.clearInterval(this.reloadInterval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ export class AppComponent implements OnInit {
|
||||
await this.lockService.lock();
|
||||
break;
|
||||
case 'locked':
|
||||
this.router.navigate(['lock']);
|
||||
this.router.navigate(['lock'], { queryParams: { refresh: true } });
|
||||
this.notificationsService.updateConnection();
|
||||
this.updateAppMenu();
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user