]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/root.component.ts
Use userId key to distinct Account or VideoChannel actor
[github/Chocobozzz/PeerTube.git] / client / src / app / root.component.ts
index ae999e0587de4489004599fc3d57ccd4349e2424..5a09e50d1d6cf4870b1d007e06242d9fc08c84f4 100644 (file)
@@ -23,19 +23,21 @@ export class RootComponent implements OnInit {
         .pipe(
           map(params => params[ 'actorName' ]),
           distinctUntilChanged(),
-          switchMap(actorName => this.actorService.getActor(actorName)),
+          switchMap(actorName => this.actorService.getActorType(actorName)),
           catchError(err => this.restExtractor.redirectTo404IfNotFound(err, 'other', [
             HttpStatusCode.BAD_REQUEST_400,
             HttpStatusCode.NOT_FOUND_404
           ]))
         )
-        .subscribe(actor => {
-          if (/\/accounts\//.test(actor.url)) {
-            this.router.navigate([ `/a/${actor.name}` ], { state: { type: 'others', obj: { status: 200 } }, skipLocationChange: true })
+        .subscribe(actorType => {
+          const actorName = this.route.snapshot.params[ 'actorName' ]
+
+          if (actorType === 'Account') {
+            this.router.navigate([ `/a/${actorName}` ], { state: { type: 'others', obj: { status: 200 } }, skipLocationChange: true })
           }
 
-          if (/\/video-channels\//.test(actor.url)) {
-            this.router.navigate([ `/c/${actor.name}` ], { state: { type: 'others', obj: { status: 200 } }, skipLocationChange: true })
+          if (actorType === 'VideoChannel') {
+            this.router.navigate([ `/c/${actorName}` ], { state: { type: 'others', obj: { status: 200 } }, skipLocationChange: true })
           }
         })
   }