]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/videos/video-list/video-recently-added.component.ts
Fix scrolling with hash in url
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / video-list / video-recently-added.component.ts
CommitLineData
9af61e84 1import { Component, OnDestroy, OnInit } from '@angular/core'
9bf9d2a5 2import { ActivatedRoute, Router } from '@angular/router'
0cd4344f 3import { immutableAssign } from '@app/shared/misc/utils'
b2731bff 4import { AuthService } from '../../core/auth'
202f6b6c 5import { AbstractVideoList } from '../../shared/video/abstract-video-list'
7b87d2d5 6import { VideoSortField } from '../../shared/video/sort-field.type'
f3aaa9a9 7import { VideoService } from '../../shared/video/video.service'
989e526a 8import { I18n } from '@ngx-translate/i18n-polyfill'
bbe0f064 9import { ScreenService } from '@app/shared/misc/screen.service'
489290b8 10import { Notifier, ServerService } from '@app/core'
93cae479 11import { HooksService } from '@app/core/plugins/hooks.service'
d3217560
RK
12import { UserService } from '@app/shared'
13import { LocalStorageService } from '@app/shared/misc/storage.service'
9bf9d2a5
C
14
15@Component({
16 selector: 'my-videos-recently-added',
202f6b6c
C
17 styleUrls: [ '../../shared/video/abstract-video-list.scss' ],
18 templateUrl: '../../shared/video/abstract-video-list.html'
9bf9d2a5 19})
9af61e84 20export class VideoRecentlyAddedComponent extends AbstractVideoList implements OnInit, OnDestroy {
989e526a 21 titlePage: string
136cce4d 22 sort: VideoSortField = '-publishedAt'
34c7f429 23 groupByDate = true
9bf9d2a5 24
3caf77d3
C
25 useUserVideoLanguagePreferences = true
26
989e526a 27 constructor (
34c7f429 28 protected i18n: I18n,
989e526a 29 protected route: ActivatedRoute,
489290b8
C
30 protected serverService: ServerService,
31 protected router: Router,
f8b2c1b4 32 protected notifier: Notifier,
989e526a 33 protected authService: AuthService,
d3217560 34 protected userService: UserService,
bbe0f064 35 protected screenService: ScreenService,
d3217560 36 protected storageService: LocalStorageService,
93cae479
C
37 private videoService: VideoService,
38 private hooks: HooksService
989e526a 39 ) {
9bf9d2a5 40 super()
989e526a
C
41
42 this.titlePage = i18n('Recently added')
9bf9d2a5
C
43 }
44
45 ngOnInit () {
46 super.ngOnInit()
cc1561f9 47
244e76a5 48 this.generateSyndicationList()
9bf9d2a5
C
49 }
50
9af61e84
C
51 ngOnDestroy () {
52 super.ngOnDestroy()
53 }
54
0cd4344f
C
55 getVideosObservable (page: number) {
56 const newPagination = immutableAssign(this.pagination, { currentPage: page })
93cae479 57 const params = {
3caf77d3
C
58 videoPagination: newPagination,
59 sort: this.sort,
3caf77d3 60 categoryOneOf: this.categoryOneOf,
440d39c5
C
61 languageOneOf: this.languageOneOf,
62 skipCount: true
93cae479
C
63 }
64
65 return this.hooks.wrapObsFun(
66 this.videoService.getVideos.bind(this.videoService),
67 params,
68 'common',
7663e55a
C
69 'filter:api.recently-added-videos.videos.list.params',
70 'filter:api.recently-added-videos.videos.list.result'
93cae479 71 )
9bf9d2a5 72 }
244e76a5
RK
73
74 generateSyndicationList () {
d59cba29 75 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf)
244e76a5 76 }
9bf9d2a5 77}