From 734a5ceb3d04088743d72babcb9b05e6142043f6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 7 Jun 2018 11:19:26 +0200 Subject: Fix account/channel pages route subscription --- .../account-video-channels.component.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'client/src/app/+accounts/account-video-channels/account-video-channels.component.ts') diff --git a/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts b/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts index a6e6dd656..ebc671113 100644 --- a/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts +++ b/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts @@ -1,20 +1,23 @@ -import { Component, OnInit } from '@angular/core' +import { Component, OnDestroy, OnInit } from '@angular/core' import { ActivatedRoute } from '@angular/router' import { Account } from '@app/shared/account/account.model' import { AccountService } from '@app/shared/account/account.service' import { VideoChannel } from '../../../../../shared/models/videos' import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' import { flatMap, map, tap } from 'rxjs/operators' +import { Subscription } from 'rxjs' @Component({ selector: 'my-account-video-channels', templateUrl: './account-video-channels.component.html', styleUrls: [ './account-video-channels.component.scss' ] }) -export class AccountVideoChannelsComponent implements OnInit { +export class AccountVideoChannelsComponent implements OnInit, OnDestroy { account: Account videoChannels: VideoChannel[] = [] + private accountSub: Subscription + constructor ( protected route: ActivatedRoute, private accountService: AccountService, @@ -23,7 +26,7 @@ export class AccountVideoChannelsComponent implements OnInit { ngOnInit () { // Parent get the account for us - this.accountService.accountLoaded + this.accountSub = this.accountService.accountLoaded .pipe( tap(account => this.account = account), flatMap(account => this.videoChannelService.listAccountVideoChannels(account)), @@ -31,4 +34,8 @@ export class AccountVideoChannelsComponent implements OnInit { ) .subscribe(videoChannels => this.videoChannels = videoChannels) } + + ngOnDestroy () { + if (this.accountSub) this.accountSub.unsubscribe() + } } -- cgit v1.2.3