aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-09-05 17:18:13 +0200
committerChocobozzz <me@florianbigard.com>2018-09-06 09:00:58 +0200
commitd7639f66af5468c5df7e92593ae0fdeab268a123 (patch)
tree8213de5a884505fbfb867a8e5c349fdab32325aa /client/src/app
parent432e7ddcc8711d6a91719ff5d8fb5365bb0de806 (diff)
downloadPeerTube-d7639f66af5468c5df7e92593ae0fdeab268a123.tar.gz
PeerTube-d7639f66af5468c5df7e92593ae0fdeab268a123.tar.zst
PeerTube-d7639f66af5468c5df7e92593ae0fdeab268a123.zip
Unsubscribe from the router
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/+my-account/my-account.component.ts13
1 files changed, 10 insertions, 3 deletions
diff --git a/client/src/app/+my-account/my-account.component.ts b/client/src/app/+my-account/my-account.component.ts
index 7100638c8..fed6e6b04 100644
--- a/client/src/app/+my-account/my-account.component.ts
+++ b/client/src/app/+my-account/my-account.component.ts
@@ -1,18 +1,21 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnDestroy, OnInit } from '@angular/core'
2import { ServerService } from '@app/core' 2import { ServerService } from '@app/core'
3import { NavigationStart, Router } from '@angular/router' 3import { NavigationStart, Router } from '@angular/router'
4import { filter } from 'rxjs/operators' 4import { filter } from 'rxjs/operators'
5import { I18n } from '@ngx-translate/i18n-polyfill' 5import { I18n } from '@ngx-translate/i18n-polyfill'
6import { Subscription } from 'rxjs'
6 7
7@Component({ 8@Component({
8 selector: 'my-my-account', 9 selector: 'my-my-account',
9 templateUrl: './my-account.component.html', 10 templateUrl: './my-account.component.html',
10 styleUrls: [ './my-account.component.scss' ] 11 styleUrls: [ './my-account.component.scss' ]
11}) 12})
12export class MyAccountComponent implements OnInit { 13export class MyAccountComponent implements OnInit, OnDestroy {
13 14
14 libraryLabel = '' 15 libraryLabel = ''
15 16
17 private routeSub: Subscription
18
16 constructor ( 19 constructor (
17 private serverService: ServerService, 20 private serverService: ServerService,
18 private router: Router, 21 private router: Router,
@@ -22,11 +25,15 @@ export class MyAccountComponent implements OnInit {
22 ngOnInit () { 25 ngOnInit () {
23 this.updateLibraryLabel(this.router.url) 26 this.updateLibraryLabel(this.router.url)
24 27
25 this.router.events 28 this.routeSub = this.router.events
26 .pipe(filter(event => event instanceof NavigationStart)) 29 .pipe(filter(event => event instanceof NavigationStart))
27 .subscribe((event: NavigationStart) => this.updateLibraryLabel(event.url)) 30 .subscribe((event: NavigationStart) => this.updateLibraryLabel(event.url))
28 } 31 }
29 32
33 ngOnDestroy () {
34 if (this.routeSub) this.routeSub.unsubscribe()
35 }
36
30 isVideoImportEnabled () { 37 isVideoImportEnabled () {
31 const importConfig = this.serverService.getConfig().import.videos 38 const importConfig = this.serverService.getConfig().import.videos
32 39