09541b370e52febb413ae2853058a40dbb6f22e0
[oweals/peertube.git] / client / src / app / +video-channels / video-channels.component.ts
1 import { Component, OnInit } from '@angular/core'
2 import { ActivatedRoute } from '@angular/router'
3 import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
4 import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
5 import { RestExtractor } from '@app/shared'
6 import { catchError } from 'rxjs/operators'
7
8 @Component({
9   templateUrl: './video-channels.component.html',
10   styleUrls: [ './video-channels.component.scss' ]
11 })
12 export class VideoChannelsComponent implements OnInit {
13   videoChannel: VideoChannel
14
15   constructor (
16     private route: ActivatedRoute,
17     private videoChannelService: VideoChannelService,
18     private restExtractor: RestExtractor
19   ) {}
20
21   ngOnInit () {
22     const videoChannelId = this.route.snapshot.params['videoChannelId']
23
24     this.videoChannelService.getVideoChannel(videoChannelId)
25         .pipe(catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 404 ])))
26         .subscribe(videoChannel => this.videoChannel = videoChannel)
27   }
28 }