mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-07-09 03:04:19 -04:00
Close any open modals when a route change occurs (#501)
This commit is contained in:
parent
e2dc9beaef
commit
24eb318967
@ -1,4 +1,5 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { NavigationStart, Router } from '@angular/router';
|
||||
import { take } from 'rxjs/operators';
|
||||
import { AccountService } from './_services/account.service';
|
||||
import { LibraryService } from './_services/library.service';
|
||||
@ -6,6 +7,8 @@ import { MessageHubService } from './_services/message-hub.service';
|
||||
import { NavService } from './_services/nav.service';
|
||||
import { PresenceHubService } from './_services/presence-hub.service';
|
||||
import { StatsService } from './_services/stats.service';
|
||||
import 'rxjs/add/operator/filter';
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
@ -16,7 +19,17 @@ export class AppComponent implements OnInit {
|
||||
|
||||
constructor(private accountService: AccountService, public navService: NavService,
|
||||
private statsService: StatsService, private messageHub: MessageHubService,
|
||||
private presenceHub: PresenceHubService, private libraryService: LibraryService) { }
|
||||
private presenceHub: PresenceHubService, private libraryService: LibraryService, private router: Router, private ngbModal: NgbModal) {
|
||||
|
||||
// Close any open modals when a route change occurs
|
||||
router.events
|
||||
.filter(event => event instanceof NavigationStart)
|
||||
.subscribe((event) => {
|
||||
if (this.ngbModal.hasOpenModals()) {
|
||||
this.ngbModal.dismissAll();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.setCurrentUser();
|
||||
|
Loading…
x
Reference in New Issue
Block a user