2 import { switchMap } from 'rxjs/operators'
3 import { Component, OnDestroy, OnInit } from '@angular/core'
4 import { ActivatedRoute, Router } from '@angular/router'
5 import { AuthService, LocalStorageService, Notifier, ScopedTokensService, ScreenService, ServerService, UserService } from '@app/core'
6 import { HooksService } from '@app/core/plugins/hooks.service'
7 import { immutableAssign } from '@app/helpers'
8 import { VideoService } from '@app/shared/shared-main'
9 import { UserSubscriptionService } from '@app/shared/shared-user-subscription'
10 import { AbstractVideoList, OwnerDisplayType } from '@app/shared/shared-video-miniature'
11 import { FeedFormat, VideoSortField } from '@shared/models'
12 import { environment } from '../../../environments/environment'
13 import { copyToClipboard } from '../../../root-helpers/utils'
16 selector: 'my-videos-user-subscriptions',
17 styleUrls: [ '../../shared/shared-video-miniature/abstract-video-list.scss' ],
18 templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html'
20 export class VideoUserSubscriptionsComponent extends AbstractVideoList implements OnInit, OnDestroy {
22 sort = '-publishedAt' as VideoSortField
23 ownerDisplayType: OwnerDisplayType = 'auto'
27 protected router: Router,
28 protected serverService: ServerService,
29 protected route: ActivatedRoute,
30 protected notifier: Notifier,
31 protected authService: AuthService,
32 protected userService: UserService,
33 protected screenService: ScreenService,
34 protected storageService: LocalStorageService,
35 private userSubscription: UserSubscriptionService,
36 private hooks: HooksService,
37 private videoService: VideoService,
38 private scopedTokensService: ScopedTokensService
42 this.titlePage = $localize`Videos from your subscriptions`
45 routerLink: '/my-library/subscriptions',
46 label: $localize`Subscriptions`,
54 const user = this.authService.getUser()
55 let feedUrl = environment.originServerUrl
57 this.authService.userInformationLoaded
58 .pipe(switchMap(() => this.scopedTokensService.getScopedTokens()))
61 const feeds = this.videoService.getVideoSubscriptionFeedUrls(user.account.id, tokens.feedToken)
62 feedUrl = feedUrl + feeds.find(f => f.format === FeedFormat.RSS).url
64 this.actions.unshift({
65 label: $localize`Copy feed URL`,
66 iconName: 'syndication',
71 copyToClipboard(feedUrl)
72 this.activateCopiedMessage()
78 this.notifier.error(err.message)
87 getVideosObservable (page: number) {
88 const newPagination = immutableAssign(this.pagination, { currentPage: page })
90 videoPagination: newPagination,
95 return this.hooks.wrapObsFun(
96 this.userSubscription.getUserSubscriptionVideos.bind(this.userSubscription),
99 'filter:api.user-subscriptions-videos.videos.list.params',
100 'filter:api.user-subscriptions-videos.videos.list.result'
104 generateSyndicationList () {
105 // not implemented yet
108 activateCopiedMessage () {
109 this.notifier.success($localize`Feed URL copied`)