diff options
author | Chocobozzz <me@florianbigard.com> | 2018-09-05 17:18:13 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-09-06 09:00:58 +0200 |
commit | d7639f66af5468c5df7e92593ae0fdeab268a123 (patch) | |
tree | 8213de5a884505fbfb867a8e5c349fdab32325aa /client/src/app | |
parent | 432e7ddcc8711d6a91719ff5d8fb5365bb0de806 (diff) | |
download | PeerTube-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.ts | 13 |
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 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | 1 | import { Component, OnDestroy, OnInit } from '@angular/core' |
2 | import { ServerService } from '@app/core' | 2 | import { ServerService } from '@app/core' |
3 | import { NavigationStart, Router } from '@angular/router' | 3 | import { NavigationStart, Router } from '@angular/router' |
4 | import { filter } from 'rxjs/operators' | 4 | import { filter } from 'rxjs/operators' |
5 | import { I18n } from '@ngx-translate/i18n-polyfill' | 5 | import { I18n } from '@ngx-translate/i18n-polyfill' |
6 | import { 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 | }) |
12 | export class MyAccountComponent implements OnInit { | 13 | export 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 | ||