]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+video-channels/video-channels.component.ts
Fix player lint
[github/Chocobozzz/PeerTube.git] / client / src / app / +video-channels / video-channels.component.ts
CommitLineData
4d089429 1import { Component, OnDestroy, OnInit } from '@angular/core'
170726f5
C
2import { ActivatedRoute } from '@angular/router'
3import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
4import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
a51bad1a 5import { RestExtractor } from '@app/shared'
4d089429
C
6import { catchError, distinctUntilChanged, map, switchMap } from 'rxjs/operators'
7import { Subscription } from 'rxjs'
170726f5
C
8
9@Component({
10 templateUrl: './video-channels.component.html',
11 styleUrls: [ './video-channels.component.scss' ]
12})
734a5ceb 13export class VideoChannelsComponent implements OnInit, OnDestroy {
170726f5
C
14 videoChannel: VideoChannel
15
734a5ceb
C
16 private routeSub: Subscription
17
170726f5
C
18 constructor (
19 private route: ActivatedRoute,
a51bad1a
C
20 private videoChannelService: VideoChannelService,
21 private restExtractor: RestExtractor
734a5ceb 22 ) { }
170726f5
C
23
24 ngOnInit () {
734a5ceb
C
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 }
170726f5 35
734a5ceb
C
36 ngOnDestroy () {
37 if (this.routeSub) this.routeSub.unsubscribe()
170726f5
C
38 }
39}