aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+video-channels
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+video-channels')
-rw-r--r--client/src/app/+video-channels/video-channel-about/video-channel-about.component.ts13
-rw-r--r--client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts8
-rw-r--r--client/src/app/+video-channels/video-channels.component.ts27
3 files changed, 35 insertions, 13 deletions
diff --git a/client/src/app/+video-channels/video-channel-about/video-channel-about.component.ts b/client/src/app/+video-channels/video-channel-about/video-channel-about.component.ts
index c5fd442c6..dc0893962 100644
--- a/client/src/app/+video-channels/video-channel-about/video-channel-about.component.ts
+++ b/client/src/app/+video-channels/video-channel-about/video-channel-about.component.ts
@@ -1,17 +1,20 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnDestroy, OnInit } from '@angular/core'
2import { ActivatedRoute } from '@angular/router' 2import { ActivatedRoute } from '@angular/router'
3import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' 3import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
4import { VideoChannel } from '@app/shared/video-channel/video-channel.model' 4import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
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-video-channel-about', 9 selector: 'my-video-channel-about',
9 templateUrl: './video-channel-about.component.html', 10 templateUrl: './video-channel-about.component.html',
10 styleUrls: [ './video-channel-about.component.scss' ] 11 styleUrls: [ './video-channel-about.component.scss' ]
11}) 12})
12export class VideoChannelAboutComponent implements OnInit { 13export class VideoChannelAboutComponent implements OnInit, OnDestroy {
13 videoChannel: VideoChannel 14 videoChannel: VideoChannel
14 15
16 private videoChannelSub: 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 VideoChannelAboutComponent implements OnInit {
20 23
21 ngOnInit () { 24 ngOnInit () {
22 // Parent get the video channel for us 25 // Parent get the video channel for us
23 this.videoChannelService.videoChannelLoaded 26 this.videoChannelSub = this.videoChannelService.videoChannelLoaded
24 .subscribe(videoChannel => this.videoChannel = videoChannel) 27 .subscribe(videoChannel => this.videoChannel = videoChannel)
25 } 28 }
26 29
30 ngOnDestroy () {
31 if (this.videoChannelSub) this.videoChannelSub.unsubscribe()
32 }
33
27 getVideoChannelDescription () { 34 getVideoChannelDescription () {
28 if (this.videoChannel.description) return this.videoChannel.description 35 if (this.videoChannel.description) return this.videoChannel.description
29 36
diff --git a/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts b/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts
index 28c591039..2d3f66994 100644
--- a/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts
+++ b/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts
@@ -11,6 +11,7 @@ import { VideoChannelService } from '@app/shared/video-channel/video-channel.ser
11import { VideoChannel } from '@app/shared/video-channel/video-channel.model' 11import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
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-video-channel-videos', 17 selector: 'my-video-channel-videos',
@@ -27,6 +28,7 @@ export class VideoChannelVideosComponent extends AbstractVideoList implements On
27 loadOnInit = false 28 loadOnInit = false
28 29
29 private videoChannel: VideoChannel 30 private videoChannel: VideoChannel
31 private videoChannelSub: Subscription
30 32
31 constructor ( 33 constructor (
32 protected router: Router, 34 protected router: Router,
@@ -48,17 +50,19 @@ export class VideoChannelVideosComponent extends AbstractVideoList implements On
48 super.ngOnInit() 50 super.ngOnInit()
49 51
50 // Parent get the video channel for us 52 // Parent get the video channel for us
51 this.videoChannelService.videoChannelLoaded 53 this.videoChannelSub = this.videoChannelService.videoChannelLoaded
52 .subscribe(videoChannel => { 54 .subscribe(videoChannel => {
53 this.videoChannel = videoChannel 55 this.videoChannel = videoChannel
54 this.currentRoute = '/video-channel/' + this.videoChannel.uuid + '/videos' 56 this.currentRoute = '/video-channel/' + this.videoChannel.uuid + '/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.videoChannelSub) this.videoChannelSub.unsubscribe()
65
62 super.ngOnDestroy() 66 super.ngOnDestroy()
63 } 67 }
64 68
diff --git a/client/src/app/+video-channels/video-channels.component.ts b/client/src/app/+video-channels/video-channels.component.ts
index 09541b370..cd0463859 100644
--- a/client/src/app/+video-channels/video-channels.component.ts
+++ b/client/src/app/+video-channels/video-channels.component.ts
@@ -1,28 +1,39 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnInit, OnDestroy } from '@angular/core'
2import { ActivatedRoute } from '@angular/router' 2import { ActivatedRoute } from '@angular/router'
3import { VideoChannel } from '@app/shared/video-channel/video-channel.model' 3import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
4import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' 4import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
5import { RestExtractor } from '@app/shared' 5import { RestExtractor } from '@app/shared'
6import { catchError } from 'rxjs/operators' 6import { catchError, switchMap, map, distinctUntilChanged } from 'rxjs/operators'
7import { Subscription } from 'rxjs/Subscription'
7 8
8@Component({ 9@Component({
9 templateUrl: './video-channels.component.html', 10 templateUrl: './video-channels.component.html',
10 styleUrls: [ './video-channels.component.scss' ] 11 styleUrls: [ './video-channels.component.scss' ]
11}) 12})
12export class VideoChannelsComponent implements OnInit { 13export class VideoChannelsComponent implements OnInit, OnDestroy {
13 videoChannel: VideoChannel 14 videoChannel: VideoChannel
14 15
16 private routeSub: Subscription
17
15 constructor ( 18 constructor (
16 private route: ActivatedRoute, 19 private route: ActivatedRoute,
17 private videoChannelService: VideoChannelService, 20 private videoChannelService: VideoChannelService,
18 private restExtractor: RestExtractor 21 private restExtractor: RestExtractor
19 ) {} 22 ) { }
20 23
21 ngOnInit () { 24 ngOnInit () {
22 const videoChannelId = this.route.snapshot.params['videoChannelId'] 25 this.routeSub = this.route.params
26 .pipe(
27 map(params => params[ 'videoChannelId' ]),
28 distinctUntilChanged(),
29 switchMap(videoChannelId => this.videoChannelService.getVideoChannel(videoChannelId)),
30 catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 404 ]))
31 )
32 .subscribe(videoChannel => this.videoChannel = videoChannel)
33
34 }
23 35
24 this.videoChannelService.getVideoChannel(videoChannelId) 36 ngOnDestroy () {
25 .pipe(catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 404 ]))) 37 if (this.routeSub) this.routeSub.unsubscribe()
26 .subscribe(videoChannel => this.videoChannel = videoChannel)
27 } 38 }
28} 39}