]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+videos/video-list/video-local.component.ts
Merge branch 'develop' into shorter-URLs-channels-accounts
[github/Chocobozzz/PeerTube.git] / client / src / app / +videos / video-list / video-local.component.ts
CommitLineData
5bcbcbe3 1import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core'
066e94c5 2import { ActivatedRoute, Router } from '@angular/router'
67ed6552 3import { AuthService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core'
93cae479 4import { HooksService } from '@app/core/plugins/hooks.service'
67ed6552
C
5import { immutableAssign } from '@app/helpers'
6import { VideoService } from '@app/shared/shared-main'
7import { AbstractVideoList } from '@app/shared/shared-video-miniature'
67ed6552 8import { UserRight, VideoFilter, VideoSortField } from '@shared/models'
066e94c5
C
9
10@Component({
11 selector: 'my-videos-local',
67ed6552
C
12 styleUrls: [ '../../shared/shared-video-miniature/abstract-video-list.scss' ],
13 templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html'
066e94c5 14})
9af61e84 15export class VideoLocalComponent extends AbstractVideoList implements OnInit, OnDestroy {
989e526a 16 titlePage: string
136cce4d 17 sort = '-publishedAt' as VideoSortField
7b87d2d5 18 filter: VideoFilter = 'local'
066e94c5 19
07f81d9d 20 loadUserVideoPreferences = true
3caf77d3 21
989e526a
C
22 constructor (
23 protected router: Router,
489290b8 24 protected serverService: ServerService,
989e526a 25 protected route: ActivatedRoute,
f8b2c1b4 26 protected notifier: Notifier,
989e526a 27 protected authService: AuthService,
d3217560 28 protected userService: UserService,
bbe0f064 29 protected screenService: ScreenService,
d3217560 30 protected storageService: LocalStorageService,
5bcbcbe3 31 protected cfr: ComponentFactoryResolver,
93cae479
C
32 private videoService: VideoService,
33 private hooks: HooksService
989e526a 34 ) {
066e94c5 35 super()
989e526a 36
66357162 37 this.titlePage = $localize`Local videos`
066e94c5
C
38 }
39
40 ngOnInit () {
41 super.ngOnInit()
cc1561f9 42
0aa52e17 43 this.enableAllFilterIfPossible()
244e76a5 44 this.generateSyndicationList()
066e94c5
C
45 }
46
9af61e84
C
47 ngOnDestroy () {
48 super.ngOnDestroy()
49 }
50
066e94c5
C
51 getVideosObservable (page: number) {
52 const newPagination = immutableAssign(this.pagination, { currentPage: page })
93cae479 53 const params = {
3caf77d3
C
54 videoPagination: newPagination,
55 sort: this.sort,
56 filter: this.filter,
57 categoryOneOf: this.categoryOneOf,
440d39c5 58 languageOneOf: this.languageOneOf,
5c20a455 59 nsfwPolicy: this.nsfwPolicy,
440d39c5 60 skipCount: true
93cae479
C
61 }
62
63 return this.hooks.wrapObsFun(
64 this.videoService.getVideos.bind(this.videoService),
65 params,
66 'common',
7663e55a
C
67 'filter:api.local-videos.videos.list.params',
68 'filter:api.local-videos.videos.list.result'
93cae479 69 )
066e94c5 70 }
244e76a5
RK
71
72 generateSyndicationList () {
d59cba29 73 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, this.filter, this.categoryOneOf)
244e76a5 74 }
017c3dca
C
75
76 toggleModerationDisplay () {
0aa52e17 77 this.filter = this.buildLocalFilter(this.filter, 'local')
017c3dca
C
78
79 this.reloadVideos()
80 }
066e94c5 81}