1 import { forkJoin, Subscription } from 'rxjs'
2 import { first, tap } from 'rxjs/operators'
3 import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core'
4 import { ActivatedRoute, Router } from '@angular/router'
5 import { AuthService, ConfirmService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core'
6 import { immutableAssign } from '@app/helpers'
7 import { Account, AccountService, VideoService } from '@app/shared/shared-main'
8 import { AbstractVideoList } from '@app/shared/shared-video-miniature'
9 import { VideoFilter } from '@shared/models'
12 selector: 'my-account-videos',
13 templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html',
15 '../../shared/shared-video-miniature/abstract-video-list.scss'
18 export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
21 loadUserVideoPreferences = true
23 filter: VideoFilter = null
25 private account: Account
26 private accountSub: Subscription
29 protected router: Router,
30 protected serverService: ServerService,
31 protected route: ActivatedRoute,
32 protected authService: AuthService,
33 protected userService: UserService,
34 protected notifier: Notifier,
35 protected confirmService: ConfirmService,
36 protected screenService: ScreenService,
37 protected storageService: LocalStorageService,
38 private accountService: AccountService,
39 private videoService: VideoService,
40 protected cfr: ComponentFactoryResolver
48 this.enableAllFilterIfPossible()
50 // Parent get the account for us
51 this.accountSub = forkJoin([
52 this.accountService.accountLoaded.pipe(first()),
53 this.onUserLoadedSubject.pipe(first())
54 ]).subscribe(([ account ]) => {
55 this.account = account
58 this.generateSyndicationList()
63 if (this.accountSub) this.accountSub.unsubscribe()
68 getVideosObservable (page: number) {
69 const newPagination = immutableAssign(this.pagination, { currentPage: page })
71 account: this.account,
72 videoPagination: newPagination,
74 nsfwPolicy: this.nsfwPolicy,
75 videoFilter: this.filter
78 return this.videoService
79 .getAccountVideos(options)
82 this.titlePage = $localize`Published ${total} videos`
87 toggleModerationDisplay () {
88 this.filter = this.buildLocalFilter(this.filter, null)
93 generateSyndicationList () {
94 this.syndicationItems = this.videoService.getAccountFeedUrls(this.account.id)
98 return this.screenService.isInMobileView()