aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts
blob: 0852c4bb75b1e5307fe4221a59f6603328449385 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { Component, OnInit } from '@angular/core'
import { ActivatedRoute } from '@angular/router'
import { Account } from '@app/shared/account/account.model'
import { AccountService } from '@app/shared/account/account.service'
import { VideoChannel } from '../../../../../shared/models/videos'
import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
import { flatMap, map, tap } from 'rxjs/operators'

@Component({
  selector: 'my-account-video-channels',
  templateUrl: './account-video-channels.component.html',
  styleUrls: [ './account-video-channels.component.scss' ]
})
export class AccountVideoChannelsComponent implements OnInit {
  account: Account
  videoChannels: VideoChannel[] = []

  constructor (
    protected route: ActivatedRoute,
    private accountService: AccountService,
    private videoChannelService: VideoChannelService
  ) { }

  ngOnInit () {
    // Parent get the account for us
    this.accountService.accountLoaded
        .pipe(
          tap(account => this.account = account),
          flatMap(account => this.videoChannelService.listAccountVideoChannels(account.id)),
          map(res => res.data)
        )
        .subscribe(videoChannels => this.videoChannels = videoChannels)
  }
}