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 {
19 // No value because we don't want a page title
22 loadUserVideoPreferences = true
24 filter: VideoFilter = null
26 private account: Account
27 private accountSub: Subscription
30 protected router: Router,
31 protected serverService: ServerService,
32 protected route: ActivatedRoute,
33 protected authService: AuthService,
34 protected userService: UserService,
35 protected notifier: Notifier,
36 protected confirmService: ConfirmService,
37 protected screenService: ScreenService,
38 protected storageService: LocalStorageService,
39 private accountService: AccountService,
40 private videoService: VideoService,
41 protected cfr: ComponentFactoryResolver
49 this.enableAllFilterIfPossible()
51 // Parent get the account for us
52 this.accountSub = forkJoin([
53 this.accountService.accountLoaded.pipe(first()),
54 this.onUserLoadedSubject.pipe(first())
55 ]).subscribe(([ account ]) => {
56 this.account = account
59 this.generateSyndicationList()
64 if (this.accountSub) this.accountSub.unsubscribe()
69 getVideosObservable (page: number) {
70 const newPagination = immutableAssign(this.pagination, { currentPage: page })
72 account: this.account,
73 videoPagination: newPagination,
75 nsfwPolicy: this.nsfwPolicy,
76 videoFilter: this.filter
79 return this.videoService
80 .getAccountVideos(options)
83 toggleModerationDisplay () {
84 this.filter = this.buildLocalFilter(this.filter, null)
89 generateSyndicationList () {
90 this.syndicationItems = this.videoService.getAccountFeedUrls(this.account.id)
94 return this.screenService.isInMobileView()