working updates.

This commit is contained in:
Jason Kulatunga 2023-09-09 18:58:20 -07:00
parent 3c02bede7a
commit 2b0a1e0d6d
1 changed files with 1 additions and 21 deletions

View File

@ -11,33 +11,13 @@ import {NavigationEnd, Router} from '@angular/router';
styleUrls: ['./toast.component.scss'] styleUrls: ['./toast.component.scss']
}) })
export class ToastComponent implements OnInit { export class ToastComponent implements OnInit {
routerSubscription: Subscription | undefined;
constructor( constructor(
public router: Router,
public toastService: ToastService, public toastService: ToastService,
public authService: AuthService,
public fastenApiService: FastenApiService,
) {} ) {}
ngOnInit(): void { ngOnInit(): void {
} }
ngAfterViewInit() {
//TODO: this is a bit kludgey.
// Ideally we want consistently listen to events, but only when the user is authenticated.
this.routerSubscription = this.router.events.subscribe((event) => {
if (event instanceof NavigationEnd) {
if(!event.url.startsWith("/auth") && this.authService.IsAuthenticated()){
console.log("user is authenticated, listening for notifications")
//user is authenticated, lets start listening for notifications
this.routerSubscription?.unsubscribe()
this.fastenApiService.listenEventBus().subscribe((event)=>{
console.log("eventbus event:", event)
//TODO: start toasts.
})
}
}
});
}
} }