2 import { Component, OnDestroy, OnInit } from '@angular/core'
3 import { ActivatedRoute, Router } from '@angular/router'
4 import { AuthService, LocalStorageService, Notifier, ScopedTokensService, ScreenService, ServerService, UserService } from '@app/core'
5 import { HooksService } from '@app/core/plugins/hooks.service'
6 import { immutableAssign } from '@app/helpers'
7 import { VideoService } from '@app/shared/shared-main'
8 import { UserSubscriptionService } from '@app/shared/shared-user-subscription'
9 import { AbstractVideoList, OwnerDisplayType } from '@app/shared/shared-video-miniature'
10 import { FeedFormat, VideoSortField } from '@shared/models'
11 import { environment } from '../../../environments/environment'
12 import { copyToClipboard } from '../../../root-helpers/utils'
15 selector: 'my-videos-user-subscriptions',
16 styleUrls: [ '../../shared/shared-video-miniature/abstract-video-list.scss' ],
17 templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html'
19 export class VideoUserSubscriptionsComponent extends AbstractVideoList implements OnInit, OnDestroy {
21 sort = '-publishedAt' as VideoSortField
22 ownerDisplayType: OwnerDisplayType = 'auto'
26 protected router: Router,
27 protected serverService: ServerService,
28 protected route: ActivatedRoute,
29 protected notifier: Notifier,
30 protected authService: AuthService,
31 protected userService: UserService,
32 protected screenService: ScreenService,
33 protected storageService: LocalStorageService,
34 private userSubscription: UserSubscriptionService,
35 private hooks: HooksService,
36 private videoService: VideoService,
37 private scopedTokensService: ScopedTokensService
41 this.titlePage = $localize`Videos from your subscriptions`
44 routerLink: '/my-library/subscriptions',
45 label: $localize`Subscriptions`,
53 const user = this.authService.getUser()
54 let feedUrl = environment.originServerUrl
56 this.scopedTokensService.getScopedTokens().subscribe(
58 const feeds = this.videoService.getVideoSubscriptionFeedUrls(user.account.id, tokens.feedToken)
59 feedUrl = feedUrl + feeds.find(f => f.format === FeedFormat.RSS).url
63 this.notifier.error(err.message)
67 this.actions.unshift({
68 label: $localize`Feed`,
69 iconName: 'syndication',
72 copyToClipboard(feedUrl)
73 this.activateCopiedMessage()
82 getVideosObservable (page: number) {
83 const newPagination = immutableAssign(this.pagination, { currentPage: page })
85 videoPagination: newPagination,
90 return this.hooks.wrapObsFun(
91 this.userSubscription.getUserSubscriptionVideos.bind(this.userSubscription),
94 'filter:api.user-subscriptions-videos.videos.list.params',
95 'filter:api.user-subscriptions-videos.videos.list.result'
99 generateSyndicationList () {
100 // not implemented yet
103 activateCopiedMessage () {
104 this.notifier.success($localize`Feed URL copied`)