Close any open modals when a route change occurs (#501)
This commit is contained in:
parent
e2dc9beaef
commit
24eb318967
1 changed files with 14 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { NavigationStart, Router } from '@angular/router';
|
||||||
import { take } from 'rxjs/operators';
|
import { take } from 'rxjs/operators';
|
||||||
import { AccountService } from './_services/account.service';
|
import { AccountService } from './_services/account.service';
|
||||||
import { LibraryService } from './_services/library.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 { NavService } from './_services/nav.service';
|
||||||
import { PresenceHubService } from './_services/presence-hub.service';
|
import { PresenceHubService } from './_services/presence-hub.service';
|
||||||
import { StatsService } from './_services/stats.service';
|
import { StatsService } from './_services/stats.service';
|
||||||
|
import 'rxjs/add/operator/filter';
|
||||||
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
|
@ -16,7 +19,17 @@ export class AppComponent implements OnInit {
|
||||||
|
|
||||||
constructor(private accountService: AccountService, public navService: NavService,
|
constructor(private accountService: AccountService, public navService: NavService,
|
||||||
private statsService: StatsService, private messageHub: MessageHubService,
|
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 {
|
ngOnInit(): void {
|
||||||
this.setCurrentUser();
|
this.setCurrentUser();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue