aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+accounts/accounts.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-06-07 11:19:26 +0200
committerChocobozzz <me@florianbigard.com>2018-06-07 11:19:26 +0200
commit734a5ceb3d04088743d72babcb9b05e6142043f6 (patch)
tree965bfbd0bf930cf4cc9568a5dc801c4e3909a1b4 /client/src/app/+accounts/accounts.component.ts
parentcc69c8db39f48b1053c246458541ccc406228711 (diff)
downloadPeerTube-734a5ceb3d04088743d72babcb9b05e6142043f6.tar.gz
PeerTube-734a5ceb3d04088743d72babcb9b05e6142043f6.tar.zst
PeerTube-734a5ceb3d04088743d72babcb9b05e6142043f6.zip
Fix account/channel pages route subscription
Diffstat (limited to 'client/src/app/+accounts/accounts.component.ts')
-rw-r--r--client/src/app/+accounts/accounts.component.ts20
1 files changed, 15 insertions, 5 deletions
diff --git a/client/src/app/+accounts/accounts.component.ts b/client/src/app/+accounts/accounts.component.ts
index 24bde61ce..2a6856c10 100644
--- a/client/src/app/+accounts/accounts.component.ts
+++ b/client/src/app/+accounts/accounts.component.ts
@@ -3,7 +3,8 @@ import { ActivatedRoute } from '@angular/router'
3import { AccountService } from '@app/shared/account/account.service' 3import { AccountService } from '@app/shared/account/account.service'
4import { Account } from '@app/shared/account/account.model' 4import { Account } from '@app/shared/account/account.model'
5import { RestExtractor } from '@app/shared' 5import { RestExtractor } from '@app/shared'
6import { catchError } from 'rxjs/operators' 6import { catchError, switchMap, distinctUntilChanged, map } from 'rxjs/operators'
7import { Subscription } from 'rxjs'
7 8
8@Component({ 9@Component({
9 templateUrl: './accounts.component.html', 10 templateUrl: './accounts.component.html',
@@ -12,6 +13,8 @@ import { catchError } from 'rxjs/operators'
12export class AccountsComponent implements OnInit { 13export class AccountsComponent implements OnInit {
13 account: Account 14 account: Account
14 15
16 private routeSub: Subscription
17
15 constructor ( 18 constructor (
16 private route: ActivatedRoute, 19 private route: ActivatedRoute,
17 private accountService: AccountService, 20 private accountService: AccountService,
@@ -19,10 +22,17 @@ export class AccountsComponent implements OnInit {
19 ) {} 22 ) {}
20 23
21 ngOnInit () { 24 ngOnInit () {
22 const accountId = this.route.snapshot.params['accountId'] 25 this.routeSub = this.route.params
26 .pipe(
27 map(params => params[ 'accountId' ]),
28 distinctUntilChanged(),
29 switchMap(accountId => this.accountService.getAccount(accountId)),
30 catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 404 ]))
31 )
32 .subscribe(account => this.account = account)
33 }
23 34
24 this.accountService.getAccount(accountId) 35 ngOnDestroy () {
25 .pipe(catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 404 ]))) 36 if (this.routeSub) this.routeSub.unsubscribe()
26 .subscribe(account => this.account = account)
27 } 37 }
28} 38}