]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+accounts/account-video-channels/account-video-channels.component.ts
Add ability to set a name to a channel
[github/Chocobozzz/PeerTube.git] / client / src / app / +accounts / account-video-channels / account-video-channels.component.ts
CommitLineData
734a5ceb 1import { Component, OnDestroy, OnInit } from '@angular/core'
d3e91a5f 2import { ActivatedRoute } from '@angular/router'
d3e91a5f
C
3import { Account } from '@app/shared/account/account.model'
4import { AccountService } from '@app/shared/account/account.service'
d3e91a5f 5import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
db400f44 6import { flatMap, map, tap } from 'rxjs/operators'
734a5ceb 7import { Subscription } from 'rxjs'
8a19bee1 8import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
d3e91a5f
C
9
10@Component({
11 selector: 'my-account-video-channels',
12 templateUrl: './account-video-channels.component.html',
13 styleUrls: [ './account-video-channels.component.scss' ]
14})
734a5ceb 15export class AccountVideoChannelsComponent implements OnInit, OnDestroy {
d3e91a5f
C
16 account: Account
17 videoChannels: VideoChannel[] = []
18
734a5ceb
C
19 private accountSub: Subscription
20
d3e91a5f
C
21 constructor (
22 protected route: ActivatedRoute,
23 private accountService: AccountService,
24 private videoChannelService: VideoChannelService
25 ) { }
26
27 ngOnInit () {
28 // Parent get the account for us
734a5ceb 29 this.accountSub = this.accountService.accountLoaded
db400f44
C
30 .pipe(
31 tap(account => this.account = account),
ad9e39fb 32 flatMap(account => this.videoChannelService.listAccountVideoChannels(account)),
db400f44
C
33 map(res => res.data)
34 )
d3e91a5f
C
35 .subscribe(videoChannels => this.videoChannels = videoChannels)
36 }
734a5ceb
C
37
38 ngOnDestroy () {
39 if (this.accountSub) this.accountSub.unsubscribe()
40 }
d3e91a5f 41}