aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+video-channels/video-channels.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/+video-channels/video-channels.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/+video-channels/video-channels.component.ts')
-rw-r--r--client/src/app/+video-channels/video-channels.component.ts27
1 files changed, 19 insertions, 8 deletions
diff --git a/client/src/app/+video-channels/video-channels.component.ts b/client/src/app/+video-channels/video-channels.component.ts
index 09541b370..cd0463859 100644
--- a/client/src/app/+video-channels/video-channels.component.ts
+++ b/client/src/app/+video-channels/video-channels.component.ts
@@ -1,28 +1,39 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnInit, OnDestroy } from '@angular/core'
2import { ActivatedRoute } from '@angular/router' 2import { ActivatedRoute } from '@angular/router'
3import { VideoChannel } from '@app/shared/video-channel/video-channel.model' 3import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
4import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' 4import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
5import { RestExtractor } from '@app/shared' 5import { RestExtractor } from '@app/shared'
6import { catchError } from 'rxjs/operators' 6import { catchError, switchMap, map, distinctUntilChanged } from 'rxjs/operators'
7import { Subscription } from 'rxjs/Subscription'
7 8
8@Component({ 9@Component({
9 templateUrl: './video-channels.component.html', 10 templateUrl: './video-channels.component.html',
10 styleUrls: [ './video-channels.component.scss' ] 11 styleUrls: [ './video-channels.component.scss' ]
11}) 12})
12export class VideoChannelsComponent implements OnInit { 13export class VideoChannelsComponent implements OnInit, OnDestroy {
13 videoChannel: VideoChannel 14 videoChannel: VideoChannel
14 15
16 private routeSub: Subscription
17
15 constructor ( 18 constructor (
16 private route: ActivatedRoute, 19 private route: ActivatedRoute,
17 private videoChannelService: VideoChannelService, 20 private videoChannelService: VideoChannelService,
18 private restExtractor: RestExtractor 21 private restExtractor: RestExtractor
19 ) {} 22 ) { }
20 23
21 ngOnInit () { 24 ngOnInit () {
22 const videoChannelId = this.route.snapshot.params['videoChannelId'] 25 this.routeSub = this.route.params
26 .pipe(
27 map(params => params[ 'videoChannelId' ]),
28 distinctUntilChanged(),
29 switchMap(videoChannelId => this.videoChannelService.getVideoChannel(videoChannelId)),
30 catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 404 ]))
31 )
32 .subscribe(videoChannel => this.videoChannel = videoChannel)
33
34 }
23 35
24 this.videoChannelService.getVideoChannel(videoChannelId) 36 ngOnDestroy () {
25 .pipe(catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 404 ]))) 37 if (this.routeSub) this.routeSub.unsubscribe()
26 .subscribe(videoChannel => this.videoChannel = videoChannel)
27 } 38 }
28} 39}