2 import { Component, OnInit } from '@angular/core'
3 import { AuthService, Notifier, ConfirmService, ScopedTokensService } from '@app/core'
4 import { VideoService } from '@app/shared/shared-main'
5 import { FeedFormat } from '@shared/models'
6 import { ScopedToken } from '@shared/models/users/user-scoped-token'
7 import { environment } from '../../../environments/environment'
10 selector: 'my-account-applications',
11 templateUrl: './my-account-applications.component.html',
12 styleUrls: [ './my-account-applications.component.scss' ]
14 export class MyAccountApplicationsComponent implements OnInit {
18 private baseURL = environment.originServerUrl
21 private authService: AuthService,
22 private scopedTokensService: ScopedTokensService,
23 private videoService: VideoService,
24 private notifier: Notifier,
25 private confirmService: ConfirmService
29 this.feedUrl = this.baseURL
30 this.scopedTokensService.getScopedTokens()
32 tokens => this.regenApplications(tokens),
35 this.notifier.error(err.message)
41 const res = await this.confirmService.confirm(
42 $localize`Renewing the token will disallow previously configured clients from retrieving the feed until they use the new token. Proceed?`,
43 $localize`Renew token`
45 if (res === false) return
47 this.scopedTokensService.renewScopedTokens().subscribe(
49 this.regenApplications(tokens)
50 this.notifier.success($localize`Token renewed. Update your client configuration accordingly.`)
54 this.notifier.error(err.message)
60 private regenApplications (tokens: ScopedToken) {
61 const user = this.authService.getUser()
62 const feeds = this.videoService.getVideoSubscriptionFeedUrls(user.account.id, tokens.feedToken)
63 this.feedUrl = this.baseURL + feeds.find(f => f.format === FeedFormat.RSS).url
64 this.feedToken = tokens.feedToken