]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+accounts/account-videos/account-videos.component.ts
modularize abstract video list header and implement video hotness recommendation...
[github/Chocobozzz/PeerTube.git] / client / src / app / +accounts / account-videos / account-videos.component.ts
CommitLineData
67ed6552
C
1import { Subscription } from 'rxjs'
2import { first, tap } from 'rxjs/operators'
5bcbcbe3 3import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core'
0626e7af 4import { ActivatedRoute, Router } from '@angular/router'
67ed6552
C
5import { AuthService, ConfirmService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core'
6import { immutableAssign } from '@app/helpers'
7import { Account, AccountService, VideoService } from '@app/shared/shared-main'
8import { AbstractVideoList } from '@app/shared/shared-video-miniature'
0aa52e17 9import { VideoFilter } from '@shared/models'
0626e7af
C
10
11@Component({
12 selector: 'my-account-videos',
67ed6552 13 templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html',
0626e7af 14 styleUrls: [
ae2dd046 15 '../../shared/shared-video-miniature/abstract-video-list.scss'
0626e7af
C
16 ]
17})
18export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
b1d40cff 19 titlePage: string
0626e7af
C
20 loadOnInit = false
21
0aa52e17
C
22 filter: VideoFilter = null
23
0626e7af 24 private account: Account
734a5ceb 25 private accountSub: Subscription
0626e7af
C
26
27 constructor (
28 protected router: Router,
489290b8 29 protected serverService: ServerService,
0626e7af
C
30 protected route: ActivatedRoute,
31 protected authService: AuthService,
d3217560 32 protected userService: UserService,
f8b2c1b4 33 protected notifier: Notifier,
0626e7af 34 protected confirmService: ConfirmService,
bbe0f064 35 protected screenService: ScreenService,
d3217560 36 protected storageService: LocalStorageService,
0626e7af 37 private accountService: AccountService,
5bcbcbe3
RK
38 private videoService: VideoService,
39 protected cfr: ComponentFactoryResolver
0626e7af
C
40 ) {
41 super()
42 }
43
44 ngOnInit () {
45 super.ngOnInit()
46
0aa52e17
C
47 this.enableAllFilterIfPossible()
48
0626e7af 49 // Parent get the account for us
734a5ceb 50 this.accountSub = this.accountService.accountLoaded
722bca90
C
51 .pipe(first())
52 .subscribe(account => {
53 this.account = account
0626e7af 54
722bca90
C
55 this.reloadVideos()
56 this.generateSyndicationList()
57 })
0626e7af
C
58 }
59
60 ngOnDestroy () {
734a5ceb
C
61 if (this.accountSub) this.accountSub.unsubscribe()
62
0626e7af
C
63 super.ngOnDestroy()
64 }
65
66 getVideosObservable (page: number) {
67 const newPagination = immutableAssign(this.pagination, { currentPage: page })
0aa52e17
C
68 const options = {
69 account: this.account,
70 videoPagination: newPagination,
71 sort: this.sort,
72 nsfwPolicy: this.nsfwPolicy,
73 videoFilter: this.filter
74 }
0626e7af 75
0bf1f265 76 return this.videoService
0aa52e17 77 .getAccountVideos(options)
b1d40cff 78 .pipe(
93cae479 79 tap(({ total }) => {
66357162 80 this.titlePage = $localize`Published ${total} videos`
b1d40cff
C
81 })
82 )
0626e7af
C
83 }
84
0aa52e17
C
85 toggleModerationDisplay () {
86 this.filter = this.buildLocalFilter(this.filter, null)
87
88 this.reloadVideos()
89 }
90
0626e7af
C
91 generateSyndicationList () {
92 this.syndicationItems = this.videoService.getAccountFeedUrls(this.account.id)
93 }
94}