From 68f6c87a27bd3616644368154914a683001f8aa6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 27 Nov 2020 15:31:09 +0100 Subject: Various front optimizations --- client/src/app/core/routing/redirect.service.ts | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'client/src/app/core/routing') 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, -- cgit v1.2.3