1
0
mirror of https://github.com/bitwarden/web synced 2025-12-10 21:33:16 +00:00

lock screen. cleanup modals on navigate

This commit is contained in:
Kyle Spearrin
2018-06-09 13:59:09 -04:00
parent 5ecb26b032
commit ea6317e3a2
7 changed files with 98 additions and 2 deletions

View File

@@ -1,3 +1,7 @@
import * as jq from 'jquery';
import * as _swal from 'sweetalert';
import { SweetAlert } from 'sweetalert/typings/core';
import {
ToasterConfig,
ToasterContainerComponent,
@@ -11,7 +15,10 @@ import {
OnDestroy,
OnInit,
} from '@angular/core';
import { Router } from '@angular/router';
import {
NavigationEnd,
Router,
} from '@angular/router';
import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';
@@ -34,6 +41,8 @@ import { UserService } from 'jslib/abstractions/user.service';
import { ConstantsService } from 'jslib/services/constants.service';
const BroadcasterSubscriptionId = 'AppComponent';
// Hack due to Angular 5.2 bug
const swal: SweetAlert = _swal as any;
@Component({
selector: 'app-root',
@@ -94,6 +103,19 @@ export class AppComponent implements OnDestroy, OnInit {
}
});
});
this.router.events.subscribe((event) => {
if (event instanceof NavigationEnd) {
const modals = Array.from(document.querySelectorAll('.modal'));
for (const modal of modals) {
(jq(modal) as any).modal('hide');
}
if (document.querySelector('.swal-modal') != null) {
swal.close(undefined);
}
}
});
}
ngOnDestroy() {