diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts index 75f4bdfe6..c5cb54ddd 100644 --- a/client/src/app/app.component.ts +++ b/client/src/app/app.component.ts @@ -1,6 +1,6 @@ import { Hotkey, HotkeysService } from 'angular2-hotkeys' import { concat } from 'rxjs' -import { filter, first, map, pairwise } from 'rxjs/operators' +import { filter, first, map, pairwise, tap } from 'rxjs/operators' import { DOCUMENT, PlatformLocation, ViewportScroller } from '@angular/common' import { AfterViewInit, Component, Inject, LOCALE_ID, OnInit, ViewChild } from '@angular/core' import { DomSanitizer, SafeHtml } from '@angular/platform-browser' diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts index 5c4616153..3f874856d 100644 --- a/client/src/app/app.module.ts +++ b/client/src/app/app.module.ts @@ -1,11 +1,10 @@ import 'focus-visible' import { APP_BASE_HREF, registerLocaleData } from '@angular/common' -import { LOCALE_ID, NgModule, TRANSLATIONS, TRANSLATIONS_FORMAT } from '@angular/core' +import { NgModule } from '@angular/core' import { BrowserModule } from '@angular/platform-browser' import { ServerService } from '@app/core' import localeOc from '@app/helpers/locales/oc' import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core' -import { buildFileLocale, getCompleteLocale, isDefaultLocale } from '@shared/core-utils/i18n' import { AppRoutingModule } from './app-routing.module' import { AppComponent } from './app.component' import { CoreModule } from './core' diff --git a/client/src/app/core/routing/redirect.service.ts b/client/src/app/core/routing/redirect.service.ts index 3982cf36f..4f4b346e2 100644 --- a/client/src/app/core/routing/redirect.service.ts +++ b/client/src/app/core/routing/redirect.service.ts @@ -11,6 +11,8 @@ export class RedirectService { private previousUrl: string private currentUrl: string + private redirectingToHomepage = false + constructor ( private router: Router, private serverService: ServerService @@ -56,10 +58,17 @@ export class RedirectService { } redirectToHomepage (skipLocationChange = false) { + if (this.redirectingToHomepage) return + + this.redirectingToHomepage = true + console.log('Redirecting to %s...', RedirectService.DEFAULT_ROUTE) this.router.navigate([ RedirectService.DEFAULT_ROUTE ], { skipLocationChange }) + .then(() => this.redirectingToHomepage = false) .catch(() => { + this.redirectingToHomepage = false + console.error( 'Cannot navigate to %s, resetting default route to %s.', RedirectService.DEFAULT_ROUTE, diff --git a/client/src/app/menu/menu.component.html b/client/src/app/menu/menu.component.html index 810466a72..bba5fdadf 100644 --- a/client/src/app/menu/menu.component.html +++ b/client/src/app/menu/menu.component.html @@ -12,7 +12,7 @@