1 import { Component, OnDestroy, OnInit } from '@angular/core'
2 import { ServerService } from '@app/core'
3 import { NavigationStart, Router } from '@angular/router'
4 import { filter } from 'rxjs/operators'
5 import { I18n } from '@ngx-translate/i18n-polyfill'
6 import { Subscription } from 'rxjs'
9 selector: 'my-my-account',
10 templateUrl: './my-account.component.html',
11 styleUrls: [ './my-account.component.scss' ]
13 export class MyAccountComponent implements OnInit, OnDestroy {
18 private routeSub: Subscription
21 private serverService: ServerService,
22 private router: Router,
27 this.updateLabels(this.router.url)
29 this.routeSub = this.router.events
30 .pipe(filter(event => event instanceof NavigationStart))
31 .subscribe((event: NavigationStart) => this.updateLabels(event.url))
35 if (this.routeSub) this.routeSub.unsubscribe()
38 isVideoImportEnabled () {
39 const importConfig = this.serverService.getConfig().import.videos
41 return importConfig.http.enabled || importConfig.torrent.enabled
44 private updateLabels (url: string) {
45 const [ path ] = url.split('?')
47 if (path.startsWith('/my-account/video-channels')) {
48 this.libraryLabel = this.i18n('Channels')
49 } else if (path.startsWith('/my-account/videos')) {
50 this.libraryLabel = this.i18n('Videos')
51 } else if (path.startsWith('/my-account/subscriptions')) {
52 this.libraryLabel = this.i18n('Subscriptions')
53 } else if (path.startsWith('/my-account/video-imports')) {
54 this.libraryLabel = this.i18n('Video imports')
56 this.libraryLabel = ''
59 if (path.startsWith('/my-account/blocklist/accounts')) {
60 this.miscLabel = this.i18n('Muted accounts')
61 } else if (path.startsWith('/my-account/blocklist/servers')) {
62 this.miscLabel = this.i18n('Muted instances')