]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+admin/follows/follows.component.ts
Add short description in config
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / follows / follows.component.ts
index 97422a41bbda5d02463fbd9df309384e3f6f7b97..f29ad384fcc9f514d9f033bac17b66885eda0ae7 100644 (file)
@@ -1,11 +1,12 @@
-import { AfterViewInit, Component, ViewChild } from '@angular/core'
+import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core'
+import { NavigationEnd, Router } from '@angular/router'
 import { TabsetComponent } from 'ngx-bootstrap/tabs'
 
 @Component({
   templateUrl: './follows.component.html',
   styleUrls: [ './follows.component.scss' ]
 })
-export class FollowsComponent implements AfterViewInit {
+export class FollowsComponent implements OnInit, AfterViewInit {
   @ViewChild('followsMenuTabs') followsMenuTabs: TabsetComponent
 
   links = [
@@ -23,6 +24,18 @@ export class FollowsComponent implements AfterViewInit {
     }
   ]
 
+  constructor (private router: Router) {}
+
+  ngOnInit () {
+    this.router.events.subscribe(
+      event => {
+        if (event instanceof NavigationEnd) {
+          this.updateActiveTab()
+        }
+      }
+    )
+  }
+
   ngAfterViewInit () {
     // Avoid issue with change detector
     setTimeout(() => this.updateActiveTab())
@@ -34,7 +47,7 @@ export class FollowsComponent implements AfterViewInit {
     for (let i = 0; i < this.links.length; i++) {
       const path = this.links[i].path
 
-      if (url.endsWith(path) === true) {
+      if (url.endsWith(path) === true && this.followsMenuTabs.tabs[i]) {
         this.followsMenuTabs.tabs[i].active = true
         return
       }