import { Component, OnInit } from '@angular/core'
import { DomSanitizer, SafeHtml } from '@angular/platform-browser'
-import { GuardsCheckStart, Router } from '@angular/router'
+import { GuardsCheckStart, Router, NavigationEnd } from '@angular/router'
import { AuthService, RedirectService, ServerService } from '@app/core'
import { isInSmallView } from '@app/shared/misc/utils'
ngOnInit () {
document.getElementById('incompatible-browser').className += ' browser-ok'
- const pathname = window.location.pathname
- if (!pathname || pathname === '/') {
- this.redirectService.redirectToHomepage()
- }
+ this.router.events.subscribe(e => {
+ if (e instanceof NavigationEnd) {
+ const pathname = window.location.pathname
+ if (!pathname || pathname === '/') {
+ this.redirectService.redirectToHomepage()
+ }
+ }
+ })
this.authService.loadClientCredentials()