]>
Commit | Line | Data |
---|---|---|
1 | import { Component, OnDestroy, OnInit } from '@angular/core' | |
2 | import { ActivatedRoute, Router } from '@angular/router' | |
3 | import { AuthService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core' | |
4 | import { HooksService } from '@app/core/plugins/hooks.service' | |
5 | import { immutableAssign } from '@app/helpers' | |
6 | import { VideoService } from '@app/shared/shared-main' | |
7 | import { UserSubscriptionService } from '@app/shared/shared-user-subscription' | |
8 | import { AbstractVideoList, OwnerDisplayType } from '@app/shared/shared-video-miniature' | |
9 | import { I18n } from '@ngx-translate/i18n-polyfill' | |
10 | import { VideoSortField } from '@shared/models' | |
11 | ||
12 | @Component({ | |
13 | selector: 'my-videos-user-subscriptions', | |
14 | styleUrls: [ '../../shared/shared-video-miniature/abstract-video-list.scss' ], | |
15 | templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html' | |
16 | }) | |
17 | export class VideoUserSubscriptionsComponent extends AbstractVideoList implements OnInit, OnDestroy { | |
18 | titlePage: string | |
19 | sort = '-publishedAt' as VideoSortField | |
20 | ownerDisplayType: OwnerDisplayType = 'auto' | |
21 | groupByDate = true | |
22 | ||
23 | constructor ( | |
24 | protected i18n: I18n, | |
25 | protected router: Router, | |
26 | protected serverService: ServerService, | |
27 | protected route: ActivatedRoute, | |
28 | protected notifier: Notifier, | |
29 | protected authService: AuthService, | |
30 | protected userService: UserService, | |
31 | protected screenService: ScreenService, | |
32 | protected storageService: LocalStorageService, | |
33 | private userSubscription: UserSubscriptionService, | |
34 | private videoService: VideoService, | |
35 | private hooks: HooksService | |
36 | ) { | |
37 | super() | |
38 | ||
39 | this.titlePage = i18n('Videos from your subscriptions') | |
40 | this.actions.push({ | |
41 | routerLink: '/my-account/subscriptions', | |
42 | label: i18n('Subscriptions'), | |
43 | iconName: 'cog' | |
44 | }) | |
45 | } | |
46 | ||
47 | ngOnInit () { | |
48 | super.ngOnInit() | |
49 | } | |
50 | ||
51 | ngOnDestroy () { | |
52 | super.ngOnDestroy() | |
53 | } | |
54 | ||
55 | getVideosObservable (page: number) { | |
56 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) | |
57 | const params = { | |
58 | videoPagination: newPagination, | |
59 | sort: this.sort, | |
60 | skipCount: true | |
61 | } | |
62 | ||
63 | return this.hooks.wrapObsFun( | |
64 | this.userSubscription.getUserSubscriptionVideos.bind(this.userSubscription), | |
65 | params, | |
66 | 'common', | |
67 | 'filter:api.user-subscriptions-videos.videos.list.params', | |
68 | 'filter:api.user-subscriptions-videos.videos.list.result' | |
69 | ) | |
70 | } | |
71 | ||
72 | generateSyndicationList () { | |
73 | // not implemented yet | |
74 | } | |
75 | } |