1 import { Subscription } from 'rxjs'
2 import { first, tap } from 'rxjs/operators'
3 import { Component, 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 {
22 filter: VideoFilter = null
24 private account: Account
25 private accountSub: Subscription
28 protected router: Router,
29 protected serverService: ServerService,
30 protected route: ActivatedRoute,
31 protected authService: AuthService,
32 protected userService: UserService,
33 protected notifier: Notifier,
34 protected confirmService: ConfirmService,
35 protected screenService: ScreenService,
36 protected storageService: LocalStorageService,
37 private accountService: AccountService,
38 private videoService: VideoService
46 this.enableAllFilterIfPossible()
48 // Parent get the account for us
49 this.accountSub = this.accountService.accountLoaded
51 .subscribe(account => {
52 this.account = account
55 this.generateSyndicationList()
60 if (this.accountSub) this.accountSub.unsubscribe()
65 getVideosObservable (page: number) {
66 const newPagination = immutableAssign(this.pagination, { currentPage: page })
68 account: this.account,
69 videoPagination: newPagination,
71 nsfwPolicy: this.nsfwPolicy,
72 videoFilter: this.filter
75 return this.videoService
76 .getAccountVideos(options)
79 this.titlePage = $localize`Published ${total} videos`
84 toggleModerationDisplay () {
85 this.filter = this.buildLocalFilter(this.filter, null)
90 generateSyndicationList () {
91 this.syndicationItems = this.videoService.getAccountFeedUrls(this.account.id)