]>
Commit | Line | Data |
---|---|---|
734a5ceb | 1 | import { Component, OnDestroy, OnInit } from '@angular/core' |
d3e91a5f | 2 | import { ActivatedRoute } from '@angular/router' |
d3e91a5f C |
3 | import { Account } from '@app/shared/account/account.model' |
4 | import { AccountService } from '@app/shared/account/account.service' | |
d3e91a5f | 5 | import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' |
db400f44 | 6 | import { flatMap, map, tap } from 'rxjs/operators' |
734a5ceb | 7 | import { Subscription } from 'rxjs' |
8a19bee1 | 8 | import { 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 | 15 | export 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 | } |