]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/core/routing/redirect.service.ts
Give moderators access to edit channels (#4608)
[github/Chocobozzz/PeerTube.git] / client / src / app / core / routing / redirect.service.ts
index cf690a4d06ecc86851d7edaa6749901f28981788..571476d1de529583b793c08ca5a2f8b3cd1fb65d 100644 (file)
@@ -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,7 +46,7 @@ export class RedirectService {
     return this.defaultTrendingAlgorithm
   }
 
-  redirectToPreviousRoute () {
+  redirectToPreviousRoute (fallbackRoute: string[] = null) {
     const exceptions = [
       '/verify-account',
       '/reset-password'
@@ -67,6 +57,10 @@ export class RedirectService {
       if (!isException) return this.router.navigateByUrl(this.previousUrl)
     }
 
+    if (fallbackRoute) {
+      return this.router.navigate(fallbackRoute)
+    }
+
     return this.redirectToHomepage()
   }