aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts39
-rw-r--r--client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.ts14
-rw-r--r--client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts15
-rw-r--r--client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts15
4 files changed, 47 insertions, 36 deletions
diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts
index a91debbef..7043a7ec9 100644
--- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts
+++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts
@@ -1,6 +1,7 @@
1import { map, switchMap } from 'rxjs/operators' 1import { from } from 'rxjs'
2import { finalize, map, switchMap, tap } from 'rxjs/operators'
2import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' 3import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
3import { MarkdownService, UserService } from '@app/core' 4import { MarkdownService, Notifier, UserService } from '@app/core'
4import { Video, VideoSortField } from '@shared/models/videos' 5import { Video, VideoSortField } from '@shared/models/videos'
5import { VideoChannel, VideoChannelService, VideoService } from '../../shared-main' 6import { VideoChannel, VideoChannelService, VideoService } from '../../shared-main'
6import { CustomMarkupComponent } from './shared' 7import { CustomMarkupComponent } from './shared'
@@ -30,25 +31,33 @@ export class ChannelMiniatureMarkupComponent implements CustomMarkupComponent, O
30 private markdown: MarkdownService, 31 private markdown: MarkdownService,
31 private channelService: VideoChannelService, 32 private channelService: VideoChannelService,
32 private videoService: VideoService, 33 private videoService: VideoService,
33 private userService: UserService 34 private userService: UserService,
35 private notifier: Notifier
34 ) { } 36 ) { }
35 37
36 ngOnInit () { 38 ngOnInit () {
37 this.channelService.getVideoChannel(this.name) 39 this.channelService.getVideoChannel(this.name)
38 .subscribe(async channel => { 40 .pipe(
39 this.channel = channel 41 tap(channel => this.channel = channel),
40 42 switchMap(() => from(this.markdown.textMarkdownToHTML(this.channel.description))),
41 this.descriptionHTML = await this.markdown.textMarkdownToHTML(channel.description) 43 tap(html => this.descriptionHTML = html),
44 switchMap(() => this.loadVideosObservable()),
45 finalize(() => this.loaded.emit(true))
46 ).subscribe(
47 ({ total, data }) => {
48 this.totalVideos = total
49 this.video = data[0]
50 },
42 51
43 this.loadVideos() 52 err => this.notifier.error('Error in channel miniature component: ' + err.message)
44 }) 53 )
45 } 54 }
46 55
47 getVideoChannelLink () { 56 getVideoChannelLink () {
48 return [ '/c', this.channel.nameWithHost ] 57 return [ '/c', this.channel.nameWithHost ]
49 } 58 }
50 59
51 private loadVideos () { 60 private loadVideosObservable () {
52 const videoOptions = { 61 const videoOptions = {
53 videoChannel: this.channel, 62 videoChannel: this.channel,
54 videoPagination: { 63 videoPagination: {
@@ -59,18 +68,10 @@ export class ChannelMiniatureMarkupComponent implements CustomMarkupComponent, O
59 count: 1 68 count: 1
60 } 69 }
61 70
62 this.userService.getAnonymousOrLoggedUser() 71 return this.userService.getAnonymousOrLoggedUser()
63 .pipe( 72 .pipe(
64 map(user => user.nsfwPolicy), 73 map(user => user.nsfwPolicy),
65 switchMap(nsfwPolicy => this.videoService.getVideoChannelVideos({ ...videoOptions, nsfwPolicy })) 74 switchMap(nsfwPolicy => this.videoService.getVideoChannelVideos({ ...videoOptions, nsfwPolicy }))
66 ) 75 )
67 .subscribe({
68 next: ({ total, data }) => {
69 this.totalVideos = total
70 this.video = data[0]
71 },
72
73 complete: () => this.loaded.emit(true)
74 })
75 } 76 }
76} 77}
diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.ts
index 42a42d711..ff8cc01db 100644
--- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.ts
+++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.ts
@@ -1,4 +1,6 @@
1import { finalize } from 'rxjs/operators'
1import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' 2import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
3import { Notifier } from '@app/core'
2import { MiniatureDisplayOptions } from '../../shared-video-miniature' 4import { MiniatureDisplayOptions } from '../../shared-video-miniature'
3import { VideoPlaylist, VideoPlaylistService } from '../../shared-video-playlist' 5import { VideoPlaylist, VideoPlaylistService } from '../../shared-video-playlist'
4import { CustomMarkupComponent } from './shared' 6import { CustomMarkupComponent } from './shared'
@@ -31,15 +33,17 @@ export class PlaylistMiniatureMarkupComponent implements CustomMarkupComponent,
31 } 33 }
32 34
33 constructor ( 35 constructor (
34 private playlistService: VideoPlaylistService 36 private playlistService: VideoPlaylistService,
37 private notifier: Notifier
35 ) { } 38 ) { }
36 39
37 ngOnInit () { 40 ngOnInit () {
38 this.playlistService.getVideoPlaylist(this.uuid) 41 this.playlistService.getVideoPlaylist(this.uuid)
39 .subscribe({ 42 .pipe(finalize(() => this.loaded.emit(true)))
40 next: playlist => this.playlist = playlist, 43 .subscribe(
44 playlist => this.playlist = playlist,
41 45
42 complete: () => this.loaded.emit(true) 46 err => this.notifier.error('Error in playlist miniature component: ' + err.message)
43 }) 47 )
44 } 48 }
45} 49}
diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts
index 6ee5123e0..47518abfd 100644
--- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts
+++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts
@@ -1,5 +1,6 @@
1import { finalize } from 'rxjs/operators'
1import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' 2import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
2import { AuthService } from '@app/core' 3import { AuthService, Notifier } from '@app/core'
3import { Video, VideoService } from '../../shared-main' 4import { Video, VideoService } from '../../shared-main'
4import { MiniatureDisplayOptions } from '../../shared-video-miniature' 5import { MiniatureDisplayOptions } from '../../shared-video-miniature'
5import { CustomMarkupComponent } from './shared' 6import { CustomMarkupComponent } from './shared'
@@ -34,7 +35,8 @@ export class VideoMiniatureMarkupComponent implements CustomMarkupComponent, OnI
34 35
35 constructor ( 36 constructor (
36 private auth: AuthService, 37 private auth: AuthService,
37 private videoService: VideoService 38 private videoService: VideoService,
39 private notifier: Notifier
38 ) { } 40 ) { }
39 41
40 getUser () { 42 getUser () {
@@ -49,10 +51,11 @@ export class VideoMiniatureMarkupComponent implements CustomMarkupComponent, OnI
49 } 51 }
50 52
51 this.videoService.getVideo({ videoId: this.uuid }) 53 this.videoService.getVideo({ videoId: this.uuid })
52 .subscribe({ 54 .pipe(finalize(() => this.loaded.emit(true)))
53 next: video => this.video = video, 55 .subscribe(
56 video => this.video = video,
54 57
55 complete: () => this.loaded.emit(true) 58 err => this.notifier.error('Error in video miniature component: ' + err.message)
56 }) 59 )
57 } 60 }
58} 61}
diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts
index 02738022e..afa4f4799 100644
--- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts
+++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts
@@ -1,5 +1,6 @@
1import { finalize } from 'rxjs/operators'
1import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' 2import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
2import { AuthService } from '@app/core' 3import { AuthService, Notifier } from '@app/core'
3import { VideoFilter, VideoSortField } from '@shared/models' 4import { VideoFilter, VideoSortField } from '@shared/models'
4import { Video, VideoService } from '../../shared-main' 5import { Video, VideoService } from '../../shared-main'
5import { MiniatureDisplayOptions } from '../../shared-video-miniature' 6import { MiniatureDisplayOptions } from '../../shared-video-miniature'
@@ -40,7 +41,8 @@ export class VideosListMarkupComponent implements CustomMarkupComponent, OnInit
40 41
41 constructor ( 42 constructor (
42 private auth: AuthService, 43 private auth: AuthService,
43 private videoService: VideoService 44 private videoService: VideoService,
45 private notifier: Notifier
44 ) { } 46 ) { }
45 47
46 getUser () { 48 getUser () {
@@ -76,10 +78,11 @@ export class VideosListMarkupComponent implements CustomMarkupComponent, OnInit
76 } 78 }
77 79
78 this.videoService.getVideos(options) 80 this.videoService.getVideos(options)
79 .subscribe({ 81 .pipe(finalize(() => this.loaded.emit(true)))
80 next: ({ data }) => this.videos = data, 82 .subscribe(
83 ({ data }) => this.videos = data,
81 84
82 complete: () => this.loaded.emit(true) 85 err => this.notifier.error('Error in videos list component: ' + err.message)
83 }) 86 )
84 } 87 }
85} 88}