]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - client/src/app/+videos/video-list/video-user-subscriptions.component.ts
allow private syndication feeds via a user feedToken
[github/Chocobozzz/PeerTube.git] / client / src / app / +videos / video-list / video-user-subscriptions.component.ts
... / ...
CommitLineData
1import { Component, OnDestroy, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router'
3import { AuthService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core'
4import { HooksService } from '@app/core/plugins/hooks.service'
5import { immutableAssign } from '@app/helpers'
6import { VideoService } from '@app/shared/shared-main'
7import { UserSubscriptionService } from '@app/shared/shared-user-subscription'
8import { AbstractVideoList, OwnerDisplayType } from '@app/shared/shared-video-miniature'
9import { VideoSortField, FeedFormat } from '@shared/models'
10import { copyToClipboard } from '../../../root-helpers/utils'
11import { environment } from '../../../environments/environment'
12
13@Component({
14 selector: 'my-videos-user-subscriptions',
15 styleUrls: [ '../../shared/shared-video-miniature/abstract-video-list.scss' ],
16 templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html'
17})
18export class VideoUserSubscriptionsComponent extends AbstractVideoList implements OnInit, OnDestroy {
19 titlePage: string
20 sort = '-publishedAt' as VideoSortField
21 ownerDisplayType: OwnerDisplayType = 'auto'
22 groupByDate = true
23
24 constructor (
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 hooks: HooksService,
35 private videoService: VideoService
36 ) {
37 super()
38
39 this.titlePage = $localize`Videos from your subscriptions`
40
41 this.actions.push({
42 routerLink: '/my-library/subscriptions',
43 label: $localize`Subscriptions`,
44 iconName: 'cog'
45 })
46 }
47
48 ngOnInit () {
49 super.ngOnInit()
50
51 const user = this.authService.getUser()
52 let feedUrl = environment.embedUrl
53 this.videoService.getVideoSubscriptionFeedUrls(user.account.id)
54 .then((feeds: any) => feedUrl = feedUrl + feeds.find((f: any) => f.format === FeedFormat.RSS).url)
55 this.actions.unshift({
56 label: $localize`Feed`,
57 iconName: 'syndication',
58 justIcon: true,
59 click: () => {
60 copyToClipboard(feedUrl)
61 this.activateCopiedMessage()
62 }
63 })
64 }
65
66 ngOnDestroy () {
67 super.ngOnDestroy()
68 }
69
70 getVideosObservable (page: number) {
71 const newPagination = immutableAssign(this.pagination, { currentPage: page })
72 const params = {
73 videoPagination: newPagination,
74 sort: this.sort,
75 skipCount: true
76 }
77
78 return this.hooks.wrapObsFun(
79 this.userSubscription.getUserSubscriptionVideos.bind(this.userSubscription),
80 params,
81 'common',
82 'filter:api.user-subscriptions-videos.videos.list.params',
83 'filter:api.user-subscriptions-videos.videos.list.result'
84 )
85 }
86
87 generateSyndicationList () {
88 // not implemented yet
89 }
90
91 activateCopiedMessage () {
92 this.notifier.success($localize`Feed URL copied`)
93 }
94}