]>
Commit | Line | Data |
---|---|---|
51548b31 C |
1 | import { AfterViewInit, Component, ViewChild } from '@angular/core' |
2 | import { TabsetComponent } from 'ngx-bootstrap/tabs' | |
3 | ||
4 | @Component({ | |
5 | templateUrl: './follows.component.html', | |
6 | styleUrls: [ './follows.component.scss' ] | |
7 | }) | |
8 | export class FollowsComponent implements AfterViewInit { | |
9 | @ViewChild('followsMenuTabs') followsMenuTabs: TabsetComponent | |
10 | ||
11 | links = [ | |
12 | { | |
13 | path: 'following-list', | |
14 | title: 'Following' | |
15 | }, | |
16 | { | |
17 | path: 'following-add', | |
18 | title: 'Follow' | |
19 | }, | |
20 | { | |
21 | path: 'followers-list', | |
22 | title: 'Followers' | |
23 | } | |
24 | ] | |
25 | ||
26 | ngAfterViewInit () { | |
27 | // Avoid issue with change detector | |
28 | setTimeout(() => this.updateActiveTab()) | |
29 | } | |
30 | ||
31 | private updateActiveTab () { | |
32 | const url = window.location.pathname | |
33 | ||
34 | for (let i = 0; i < this.links.length; i++) { | |
35 | const path = this.links[i].path | |
36 | ||
37 | if (url.endsWith(path) === true) { | |
38 | this.followsMenuTabs.tabs[i].active = true | |
39 | return | |
40 | } | |
41 | } | |
42 | } | |
43 | } |