]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+video-channels/video-channels.component.ts
Videos overview page: first version
[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'
2d3741d6 8import { AuthService } from '@app/core'
170726f5
C
9
10@Component({
11 templateUrl: './video-channels.component.html',
12 styleUrls: [ './video-channels.component.scss' ]
13})
734a5ceb 14export class VideoChannelsComponent implements OnInit, OnDestroy {
170726f5
C
15 videoChannel: VideoChannel
16
734a5ceb
C
17 private routeSub: Subscription
18
170726f5
C
19 constructor (
20 private route: ActivatedRoute,
2d3741d6 21 private authService: AuthService,
a51bad1a
C
22 private videoChannelService: VideoChannelService,
23 private restExtractor: RestExtractor
734a5ceb 24 ) { }
170726f5
C
25
26 ngOnInit () {
734a5ceb
C
27 this.routeSub = this.route.params
28 .pipe(
29 map(params => params[ 'videoChannelId' ]),
30 distinctUntilChanged(),
31 switchMap(videoChannelId => this.videoChannelService.getVideoChannel(videoChannelId)),
32 catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 404 ]))
33 )
34 .subscribe(videoChannel => this.videoChannel = videoChannel)
35
36 }
170726f5 37
734a5ceb
C
38 ngOnDestroy () {
39 if (this.routeSub) this.routeSub.unsubscribe()
170726f5 40 }
2d3741d6
C
41
42 isUserLoggedIn () {
43 return this.authService.isLoggedIn()
44 }
170726f5 45}