diff options
author | Chocobozzz <me@florianbigard.com> | 2018-06-07 11:19:26 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-06-07 11:19:26 +0200 |
commit | 734a5ceb3d04088743d72babcb9b05e6142043f6 (patch) | |
tree | 965bfbd0bf930cf4cc9568a5dc801c4e3909a1b4 /client/src/app/+accounts/account-video-channels/account-video-channels.component.ts | |
parent | cc69c8db39f48b1053c246458541ccc406228711 (diff) | |
download | PeerTube-734a5ceb3d04088743d72babcb9b05e6142043f6.tar.gz PeerTube-734a5ceb3d04088743d72babcb9b05e6142043f6.tar.zst PeerTube-734a5ceb3d04088743d72babcb9b05e6142043f6.zip |
Fix account/channel pages route subscription
Diffstat (limited to 'client/src/app/+accounts/account-video-channels/account-video-channels.component.ts')
-rw-r--r-- | client/src/app/+accounts/account-video-channels/account-video-channels.component.ts | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts b/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts index a6e6dd656..ebc671113 100644 --- a/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts +++ b/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts | |||
@@ -1,20 +1,23 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | 1 | import { Component, OnDestroy, OnInit } from '@angular/core' |
2 | import { ActivatedRoute } from '@angular/router' | 2 | import { ActivatedRoute } from '@angular/router' |
3 | import { Account } from '@app/shared/account/account.model' | 3 | import { Account } from '@app/shared/account/account.model' |
4 | import { AccountService } from '@app/shared/account/account.service' | 4 | import { AccountService } from '@app/shared/account/account.service' |
5 | import { VideoChannel } from '../../../../../shared/models/videos' | 5 | import { VideoChannel } from '../../../../../shared/models/videos' |
6 | import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' | 6 | import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' |
7 | import { flatMap, map, tap } from 'rxjs/operators' | 7 | import { flatMap, map, tap } from 'rxjs/operators' |
8 | import { Subscription } from 'rxjs' | ||
8 | 9 | ||
9 | @Component({ | 10 | @Component({ |
10 | selector: 'my-account-video-channels', | 11 | selector: 'my-account-video-channels', |
11 | templateUrl: './account-video-channels.component.html', | 12 | templateUrl: './account-video-channels.component.html', |
12 | styleUrls: [ './account-video-channels.component.scss' ] | 13 | styleUrls: [ './account-video-channels.component.scss' ] |
13 | }) | 14 | }) |
14 | export class AccountVideoChannelsComponent implements OnInit { | 15 | export class AccountVideoChannelsComponent implements OnInit, OnDestroy { |
15 | account: Account | 16 | account: Account |
16 | videoChannels: VideoChannel[] = [] | 17 | videoChannels: VideoChannel[] = [] |
17 | 18 | ||
19 | private accountSub: Subscription | ||
20 | |||
18 | constructor ( | 21 | constructor ( |
19 | protected route: ActivatedRoute, | 22 | protected route: ActivatedRoute, |
20 | private accountService: AccountService, | 23 | private accountService: AccountService, |
@@ -23,7 +26,7 @@ export class AccountVideoChannelsComponent implements OnInit { | |||
23 | 26 | ||
24 | ngOnInit () { | 27 | ngOnInit () { |
25 | // Parent get the account for us | 28 | // Parent get the account for us |
26 | this.accountService.accountLoaded | 29 | this.accountSub = this.accountService.accountLoaded |
27 | .pipe( | 30 | .pipe( |
28 | tap(account => this.account = account), | 31 | tap(account => this.account = account), |
29 | flatMap(account => this.videoChannelService.listAccountVideoChannels(account)), | 32 | flatMap(account => this.videoChannelService.listAccountVideoChannels(account)), |
@@ -31,4 +34,8 @@ export class AccountVideoChannelsComponent implements OnInit { | |||
31 | ) | 34 | ) |
32 | .subscribe(videoChannels => this.videoChannels = videoChannels) | 35 | .subscribe(videoChannels => this.videoChannels = videoChannels) |
33 | } | 36 | } |
37 | |||
38 | ngOnDestroy () { | ||
39 | if (this.accountSub) this.accountSub.unsubscribe() | ||
40 | } | ||
34 | } | 41 | } |