1 import { Component, OnDestroy, OnInit } from '@angular/core'
2 import { ActivatedRoute } from '@angular/router'
3 import { Account } from '@app/shared/account/account.model'
4 import { AccountService } from '@app/shared/account/account.service'
5 import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
6 import { flatMap, map, tap } from 'rxjs/operators'
7 import { Subscription } from 'rxjs'
8 import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
11 selector: 'my-account-video-channels',
12 templateUrl: './account-video-channels.component.html',
13 styleUrls: [ './account-video-channels.component.scss' ]
15 export class AccountVideoChannelsComponent implements OnInit, OnDestroy {
17 videoChannels: VideoChannel[] = []
19 private accountSub: Subscription
22 protected route: ActivatedRoute,
23 private accountService: AccountService,
24 private videoChannelService: VideoChannelService
28 // Parent get the account for us
29 this.accountSub = this.accountService.accountLoaded
31 tap(account => this.account = account),
32 flatMap(account => this.videoChannelService.listAccountVideoChannels(account)),
35 .subscribe(videoChannels => this.videoChannels = videoChannels)
39 if (this.accountSub) this.accountSub.unsubscribe()