1 import { Subscription } from 'rxjs'
2 import { first } from 'rxjs/operators'
3 import { Component, OnDestroy, OnInit } from '@angular/core'
4 import { ComponentPaginationLight, DisableForReuseHook, ScreenService } from '@app/core'
5 import { Account, AccountService, VideoService } from '@app/shared/shared-main'
6 import { VideoFilters } from '@app/shared/shared-video-miniature'
7 import { VideoSortField } from '@shared/models'
10 selector: 'my-account-videos',
11 templateUrl: './account-videos.component.html'
13 export class AccountVideosComponent implements OnInit, OnDestroy, DisableForReuseHook {
14 getVideosObservableFunction = this.getVideosObservable.bind(this)
15 getSyndicationItemsFunction = this.getSyndicationItems.bind(this)
17 title = $localize`Videos`
18 defaultSort = '-publishedAt' as VideoSortField
23 private accountSub: Subscription
26 private screenService: ScreenService,
27 private accountService: AccountService,
28 private videoService: VideoService
33 // Parent get the account for us
34 this.accountService.accountLoaded.pipe(first())
35 .subscribe(account => this.account = account)
39 if (this.accountSub) this.accountSub.unsubscribe()
42 getVideosObservable (pagination: ComponentPaginationLight, filters: VideoFilters) {
44 ...filters.toVideosAPIObject(),
46 videoPagination: pagination,
47 account: this.account,
51 return this.videoService.getAccountVideos(options)
54 getSyndicationItems () {
55 return this.videoService.getAccountFeedUrls(this.account.id)
59 return this.screenService.isInMobileView()