aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+accounts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-06-07 11:19:26 +0200
committerChocobozzz <me@florianbigard.com>2018-06-07 11:19:26 +0200
commit734a5ceb3d04088743d72babcb9b05e6142043f6 (patch)
tree965bfbd0bf930cf4cc9568a5dc801c4e3909a1b4 /client/src/app/+accounts
parentcc69c8db39f48b1053c246458541ccc406228711 (diff)
downloadPeerTube-734a5ceb3d04088743d72babcb9b05e6142043f6.tar.gz
PeerTube-734a5ceb3d04088743d72babcb9b05e6142043f6.tar.zst
PeerTube-734a5ceb3d04088743d72babcb9b05e6142043f6.zip
Fix account/channel pages route subscription
Diffstat (limited to 'client/src/app/+accounts')
-rw-r--r--client/src/app/+accounts/account-about/account-about.component.ts13
-rw-r--r--client/src/app/+accounts/account-video-channels/account-video-channels.component.ts13
-rw-r--r--client/src/app/+accounts/account-videos/account-videos.component.ts10
-rw-r--r--client/src/app/+accounts/accounts.component.ts20
4 files changed, 42 insertions, 14 deletions
diff --git a/client/src/app/+accounts/account-about/account-about.component.ts b/client/src/app/+accounts/account-about/account-about.component.ts
index 4086510ba..c0e793754 100644
--- a/client/src/app/+accounts/account-about/account-about.component.ts
+++ b/client/src/app/+accounts/account-about/account-about.component.ts
@@ -1,17 +1,20 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnInit, OnDestroy } from '@angular/core'
2import { ActivatedRoute } from '@angular/router' 2import { ActivatedRoute } from '@angular/router'
3import { Account } from '@app/shared/account/account.model' 3import { Account } from '@app/shared/account/account.model'
4import { AccountService } from '@app/shared/account/account.service' 4import { AccountService } from '@app/shared/account/account.service'
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-account-about', 9 selector: 'my-account-about',
9 templateUrl: './account-about.component.html', 10 templateUrl: './account-about.component.html',
10 styleUrls: [ './account-about.component.scss' ] 11 styleUrls: [ './account-about.component.scss' ]
11}) 12})
12export class AccountAboutComponent implements OnInit { 13export class AccountAboutComponent implements OnInit, OnDestroy {
13 account: Account 14 account: Account
14 15
16 private accountSub: Subscription
17
15 constructor ( 18 constructor (
16 private route: ActivatedRoute, 19 private route: ActivatedRoute,
17 private i18n: I18n, 20 private i18n: I18n,
@@ -20,10 +23,14 @@ export class AccountAboutComponent implements OnInit {
20 23
21 ngOnInit () { 24 ngOnInit () {
22 // Parent get the account for us 25 // Parent get the account for us
23 this.accountService.accountLoaded 26 this.accountSub = this.accountService.accountLoaded
24 .subscribe(account => this.account = account) 27 .subscribe(account => this.account = account)
25 } 28 }
26 29
30 ngOnDestroy () {
31 if (this.accountSub) this.accountSub.unsubscribe()
32 }
33
27 getAccountDescription () { 34 getAccountDescription () {
28 if (this.account.description) return this.account.description 35 if (this.account.description) return this.account.description
29 36
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 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnDestroy, OnInit } from '@angular/core'
2import { ActivatedRoute } from '@angular/router' 2import { ActivatedRoute } from '@angular/router'
3import { Account } from '@app/shared/account/account.model' 3import { Account } from '@app/shared/account/account.model'
4import { AccountService } from '@app/shared/account/account.service' 4import { AccountService } from '@app/shared/account/account.service'
5import { VideoChannel } from '../../../../../shared/models/videos' 5import { VideoChannel } from '../../../../../shared/models/videos'
6import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' 6import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
7import { flatMap, map, tap } from 'rxjs/operators' 7import { flatMap, map, tap } from 'rxjs/operators'
8import { Subscription } from 'rxjs'
8 9
9@Component({ 10@Component({
10 selector: 'my-account-video-channels', 11 selector: 'my-account-video-channels',
11 templateUrl: './account-video-channels.component.html', 12 templateUrl: './account-video-channels.component.html',
12 styleUrls: [ './account-video-channels.component.scss' ] 13 styleUrls: [ './account-video-channels.component.scss' ]
13}) 14})
14export class AccountVideoChannelsComponent implements OnInit { 15export class AccountVideoChannelsComponent implements OnInit, OnDestroy {
15 account: Account 16 account: Account
16 videoChannels: VideoChannel[] = [] 17 videoChannels: VideoChannel[] = []
17 18
19 private accountSub: Subscription
20
18 constructor ( 21 constructor (
19 protected route: ActivatedRoute, 22 protected route: ActivatedRoute,
20 private accountService: AccountService, 23 private accountService: AccountService,
@@ -23,7 +26,7 @@ export class AccountVideoChannelsComponent implements OnInit {
23 26
24 ngOnInit () { 27 ngOnInit () {
25 // Parent get the account for us 28 // Parent get the account for us
26 this.accountService.accountLoaded 29 this.accountSub = this.accountService.accountLoaded
27 .pipe( 30 .pipe(
28 tap(account => this.account = account), 31 tap(account => this.account = account),
29 flatMap(account => this.videoChannelService.listAccountVideoChannels(account)), 32 flatMap(account => this.videoChannelService.listAccountVideoChannels(account)),
@@ -31,4 +34,8 @@ export class AccountVideoChannelsComponent implements OnInit {
31 ) 34 )
32 .subscribe(videoChannels => this.videoChannels = videoChannels) 35 .subscribe(videoChannels => this.videoChannels = videoChannels)
33 } 36 }
37
38 ngOnDestroy () {
39 if (this.accountSub) this.accountSub.unsubscribe()
40 }
34} 41}
diff --git a/client/src/app/+accounts/account-videos/account-videos.component.ts b/client/src/app/+accounts/account-videos/account-videos.component.ts
index 476f04024..5e3dbb6b3 100644
--- a/client/src/app/+accounts/account-videos/account-videos.component.ts
+++ b/client/src/app/+accounts/account-videos/account-videos.component.ts
@@ -11,6 +11,7 @@ import { Account } from '@app/shared/account/account.model'
11import { AccountService } from '@app/shared/account/account.service' 11import { AccountService } from '@app/shared/account/account.service'
12import { tap } from 'rxjs/operators' 12import { tap } from 'rxjs/operators'
13import { I18n } from '@ngx-translate/i18n-polyfill' 13import { I18n } from '@ngx-translate/i18n-polyfill'
14import { Subscription } from 'rxjs'
14 15
15@Component({ 16@Component({
16 selector: 'my-account-videos', 17 selector: 'my-account-videos',
@@ -27,6 +28,7 @@ export class AccountVideosComponent extends AbstractVideoList implements OnInit,
27 loadOnInit = false 28 loadOnInit = false
28 29
29 private account: Account 30 private account: Account
31 private accountSub: Subscription
30 32
31 constructor ( 33 constructor (
32 protected router: Router, 34 protected router: Router,
@@ -48,17 +50,19 @@ export class AccountVideosComponent extends AbstractVideoList implements OnInit,
48 super.ngOnInit() 50 super.ngOnInit()
49 51
50 // Parent get the account for us 52 // Parent get the account for us
51 this.accountService.accountLoaded 53 this.accountSub = this.accountService.accountLoaded
52 .subscribe(account => { 54 .subscribe(account => {
53 this.account = account 55 this.account = account
54 this.currentRoute = '/account/' + this.account.id + '/videos' 56 this.currentRoute = '/account/' + this.account.nameWithHost + '/videos'
55 57
56 this.loadMoreVideos(this.pagination.currentPage) 58 this.reloadVideos()
57 this.generateSyndicationList() 59 this.generateSyndicationList()
58 }) 60 })
59 } 61 }
60 62
61 ngOnDestroy () { 63 ngOnDestroy () {
64 if (this.accountSub) this.accountSub.unsubscribe()
65
62 super.ngOnDestroy() 66 super.ngOnDestroy()
63 } 67 }
64 68
diff --git a/client/src/app/+accounts/accounts.component.ts b/client/src/app/+accounts/accounts.component.ts
index 24bde61ce..2a6856c10 100644
--- a/client/src/app/+accounts/accounts.component.ts
+++ b/client/src/app/+accounts/accounts.component.ts
@@ -3,7 +3,8 @@ import { ActivatedRoute } from '@angular/router'
3import { AccountService } from '@app/shared/account/account.service' 3import { AccountService } from '@app/shared/account/account.service'
4import { Account } from '@app/shared/account/account.model' 4import { Account } from '@app/shared/account/account.model'
5import { RestExtractor } from '@app/shared' 5import { RestExtractor } from '@app/shared'
6import { catchError } from 'rxjs/operators' 6import { catchError, switchMap, distinctUntilChanged, map } from 'rxjs/operators'
7import { Subscription } from 'rxjs'
7 8
8@Component({ 9@Component({
9 templateUrl: './accounts.component.html', 10 templateUrl: './accounts.component.html',
@@ -12,6 +13,8 @@ import { catchError } from 'rxjs/operators'
12export class AccountsComponent implements OnInit { 13export class AccountsComponent implements OnInit {
13 account: Account 14 account: Account
14 15
16 private routeSub: Subscription
17
15 constructor ( 18 constructor (
16 private route: ActivatedRoute, 19 private route: ActivatedRoute,
17 private accountService: AccountService, 20 private accountService: AccountService,
@@ -19,10 +22,17 @@ export class AccountsComponent implements OnInit {
19 ) {} 22 ) {}
20 23
21 ngOnInit () { 24 ngOnInit () {
22 const accountId = this.route.snapshot.params['accountId'] 25 this.routeSub = this.route.params
26 .pipe(
27 map(params => params[ 'accountId' ]),
28 distinctUntilChanged(),
29 switchMap(accountId => this.accountService.getAccount(accountId)),
30 catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 404 ]))
31 )
32 .subscribe(account => this.account = account)
33 }
23 34
24 this.accountService.getAccount(accountId) 35 ngOnDestroy () {
25 .pipe(catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 404 ]))) 36 if (this.routeSub) this.routeSub.unsubscribe()
26 .subscribe(account => this.account = account)
27 } 37 }
28} 38}