]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - 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
22a16e36
C
1import { Component, OnDestroy, OnInit } from '@angular/core'
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 5import { immutableAssign } from '@app/helpers'
afff310e 6import { VideoService } from '@app/shared/shared-main'
67ed6552
C
7import { UserSubscriptionService } from '@app/shared/shared-user-subscription'
8import { AbstractVideoList, OwnerDisplayType } from '@app/shared/shared-video-miniature'
afff310e
RK
9import { VideoSortField, FeedFormat } from '@shared/models'
10import { copyToClipboard } from '../../../root-helpers/utils'
11import { environment } from '../../../environments/environment'
22a16e36
C
12
13@Component({
14 selector: 'my-videos-user-subscriptions',
67ed6552
C
15 styleUrls: [ '../../shared/shared-video-miniature/abstract-video-list.scss' ],
16 templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html'
22a16e36
C
17})
18export class VideoUserSubscriptionsComponent extends AbstractVideoList implements OnInit, OnDestroy {
19 titlePage: string
22a16e36
C
20 sort = '-publishedAt' as VideoSortField
21 ownerDisplayType: OwnerDisplayType = 'auto'
34c7f429 22 groupByDate = true
22a16e36
C
23
24 constructor (
25 protected router: Router,
489290b8 26 protected serverService: ServerService,
22a16e36 27 protected route: ActivatedRoute,
f8b2c1b4 28 protected notifier: Notifier,
22a16e36 29 protected authService: AuthService,
d3217560 30 protected userService: UserService,
22a16e36 31 protected screenService: ScreenService,
d3217560 32 protected storageService: LocalStorageService,
67ed6552 33 private userSubscription: UserSubscriptionService,
afff310e
RK
34 private hooks: HooksService,
35 private videoService: VideoService
22a16e36
C
36 ) {
37 super()
38
66357162 39 this.titlePage = $localize`Videos from your subscriptions`
afff310e 40
13adf228 41 this.actions.push({
17119e4a 42 routerLink: '/my-library/subscriptions',
66357162 43 label: $localize`Subscriptions`,
13adf228
RK
44 iconName: 'cog'
45 })
22a16e36
C
46 }
47
48 ngOnInit () {
49 super.ngOnInit()
afff310e
RK
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 })
22a16e36
C
64 }
65
66 ngOnDestroy () {
67 super.ngOnDestroy()
68 }
69
70 getVideosObservable (page: number) {
71 const newPagination = immutableAssign(this.pagination, { currentPage: page })
93cae479
C
72 const params = {
73 videoPagination: newPagination,
440d39c5
C
74 sort: this.sort,
75 skipCount: true
93cae479 76 }
22a16e36 77
93cae479 78 return this.hooks.wrapObsFun(
67ed6552 79 this.userSubscription.getUserSubscriptionVideos.bind(this.userSubscription),
93cae479
C
80 params,
81 'common',
7663e55a
C
82 'filter:api.user-subscriptions-videos.videos.list.params',
83 'filter:api.user-subscriptions-videos.videos.list.result'
93cae479 84 )
22a16e36
C
85 }
86
87 generateSyndicationList () {
88 // not implemented yet
89 }
afff310e
RK
90
91 activateCopiedMessage () {
92 this.notifier.success($localize`Feed URL copied`)
93 }
22a16e36 94}