X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fcore%2Frouting%2Fredirect.service.ts;h=d4cb0436e54324b2b609805c5094ed857833966b;hb=cb28bb92daf1a0e123bc0144030c2bc65b865f4a;hp=cf690a4d06ecc86851d7edaa6749901f28981788;hpb=5b1a6d45b5d6e50102e1c7c8c845401b76b11b4d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/core/routing/redirect.service.ts b/client/src/app/core/routing/redirect.service.ts index cf690a4d0..d4cb0436e 100644 --- a/client/src/app/core/routing/redirect.service.ts +++ b/client/src/app/core/routing/redirect.service.ts @@ -20,24 +20,14 @@ export class RedirectService { private serverService: ServerService ) { // The config is first loaded from the cache so try to get the default route - const tmpConfig = this.serverService.getTmpConfig() - if (tmpConfig?.instance?.defaultClientRoute) { - this.defaultRoute = tmpConfig.instance.defaultClientRoute + const config = this.serverService.getHTMLConfig() + if (config?.instance?.defaultClientRoute) { + this.defaultRoute = config.instance.defaultClientRoute } - if (tmpConfig?.trending?.videos?.algorithms?.default) { - this.defaultTrendingAlgorithm = tmpConfig.trending.videos.algorithms.default + if (config?.trending?.videos?.algorithms?.default) { + this.defaultTrendingAlgorithm = config.trending.videos.algorithms.default } - // Load default route - this.serverService.getConfig() - .subscribe(config => { - const defaultRouteConfig = config.instance.defaultClientRoute - const defaultTrendingConfig = config.trending.videos.algorithms.default - - if (defaultRouteConfig) this.defaultRoute = defaultRouteConfig - if (defaultTrendingConfig) this.defaultTrendingAlgorithm = defaultTrendingConfig - }) - // Track previous url this.currentUrl = this.router.url router.events.subscribe(event => { @@ -56,17 +46,25 @@ export class RedirectService { return this.defaultTrendingAlgorithm } - redirectToPreviousRoute () { + getPreviousUrl () { + return this.previousUrl + } + + redirectToPreviousRoute (fallbackRoute?: string) { const exceptions = [ '/verify-account', '/reset-password' ] - if (this.previousUrl) { + if (this.previousUrl && this.previousUrl !== '/') { const isException = exceptions.find(e => this.previousUrl.startsWith(e)) if (!isException) return this.router.navigateByUrl(this.previousUrl) } + if (fallbackRoute) { + return this.router.navigateByUrl(fallbackRoute) + } + return this.redirectToHomepage() }