]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+accounts/account-videos/account-videos.component.ts
Fix lint
[github/Chocobozzz/PeerTube.git] / client / src / app / +accounts / account-videos / account-videos.component.ts
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'
10
11 @Component({
12 selector: 'my-account-videos',
13 templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html',
14 styleUrls: [
15 '../../shared/shared-video-miniature/abstract-video-list.scss'
16 ]
17 })
18 export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
19 // No value because we don't want a page title
20 titlePage: string
21 loadOnInit = false
22 loadUserVideoPreferences = true
23
24 filter: VideoFilter = null
25
26 private account: Account
27 private accountSub: Subscription
28
29 constructor (
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
42 ) {
43 super()
44 }
45
46 ngOnInit () {
47 super.ngOnInit()
48
49 this.enableAllFilterIfPossible()
50
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
57
58 this.reloadVideos()
59 this.generateSyndicationList()
60 })
61 }
62
63 ngOnDestroy () {
64 if (this.accountSub) this.accountSub.unsubscribe()
65
66 super.ngOnDestroy()
67 }
68
69 getVideosObservable (page: number) {
70 const newPagination = immutableAssign(this.pagination, { currentPage: page })
71 const options = {
72 account: this.account,
73 videoPagination: newPagination,
74 sort: this.sort,
75 nsfwPolicy: this.nsfwPolicy,
76 videoFilter: this.filter
77 }
78
79 return this.videoService
80 .getAccountVideos(options)
81 }
82
83 toggleModerationDisplay () {
84 this.filter = this.buildLocalFilter(this.filter, null)
85
86 this.reloadVideos()
87 }
88
89 generateSyndicationList () {
90 this.syndicationItems = this.videoService.getAccountFeedUrls(this.account.id)
91 }
92
93 displayAsRow () {
94 return this.screenService.isInMobileView()
95 }
96 }