-import { map, switchMap } from 'rxjs/operators'
+import { from } from 'rxjs'
+import { finalize, map, switchMap, tap } from 'rxjs/operators'
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
-import { MarkdownService, UserService } from '@app/core'
+import { MarkdownService, Notifier, UserService } from '@app/core'
import { Video, VideoSortField } from '@shared/models/videos'
import { VideoChannel, VideoChannelService, VideoService } from '../../shared-main'
import { CustomMarkupComponent } from './shared'
private markdown: MarkdownService,
private channelService: VideoChannelService,
private videoService: VideoService,
- private userService: UserService
+ private userService: UserService,
+ private notifier: Notifier
) { }
ngOnInit () {
this.channelService.getVideoChannel(this.name)
- .subscribe(async channel => {
- this.channel = channel
-
- this.descriptionHTML = await this.markdown.textMarkdownToHTML(channel.description)
+ .pipe(
+ tap(channel => this.channel = channel),
+ switchMap(() => from(this.markdown.textMarkdownToHTML(this.channel.description))),
+ tap(html => this.descriptionHTML = html),
+ switchMap(() => this.loadVideosObservable()),
+ finalize(() => this.loaded.emit(true))
+ ).subscribe(
+ ({ total, data }) => {
+ this.totalVideos = total
+ this.video = data[0]
+ },
- this.loadVideos()
- })
+ err => this.notifier.error('Error in channel miniature component: ' + err.message)
+ )
}
getVideoChannelLink () {
return [ '/c', this.channel.nameWithHost ]
}
- private loadVideos () {
+ private loadVideosObservable () {
const videoOptions = {
videoChannel: this.channel,
videoPagination: {
count: 1
}
- this.userService.getAnonymousOrLoggedUser()
+ return this.userService.getAnonymousOrLoggedUser()
.pipe(
map(user => user.nsfwPolicy),
switchMap(nsfwPolicy => this.videoService.getVideoChannelVideos({ ...videoOptions, nsfwPolicy }))
)
- .subscribe({
- next: ({ total, data }) => {
- this.totalVideos = total
- this.video = data[0]
- },
-
- complete: () => this.loaded.emit(true)
- })
}
}
+import { finalize } from 'rxjs/operators'
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
+import { Notifier } from '@app/core'
import { MiniatureDisplayOptions } from '../../shared-video-miniature'
import { VideoPlaylist, VideoPlaylistService } from '../../shared-video-playlist'
import { CustomMarkupComponent } from './shared'
}
constructor (
- private playlistService: VideoPlaylistService
+ private playlistService: VideoPlaylistService,
+ private notifier: Notifier
) { }
ngOnInit () {
this.playlistService.getVideoPlaylist(this.uuid)
- .subscribe({
- next: playlist => this.playlist = playlist,
+ .pipe(finalize(() => this.loaded.emit(true)))
+ .subscribe(
+ playlist => this.playlist = playlist,
- complete: () => this.loaded.emit(true)
- })
+ err => this.notifier.error('Error in playlist miniature component: ' + err.message)
+ )
}
}
+import { finalize } from 'rxjs/operators'
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
-import { AuthService } from '@app/core'
+import { AuthService, Notifier } from '@app/core'
import { Video, VideoService } from '../../shared-main'
import { MiniatureDisplayOptions } from '../../shared-video-miniature'
import { CustomMarkupComponent } from './shared'
constructor (
private auth: AuthService,
- private videoService: VideoService
+ private videoService: VideoService,
+ private notifier: Notifier
) { }
getUser () {
}
this.videoService.getVideo({ videoId: this.uuid })
- .subscribe({
- next: video => this.video = video,
+ .pipe(finalize(() => this.loaded.emit(true)))
+ .subscribe(
+ video => this.video = video,
- complete: () => this.loaded.emit(true)
- })
+ err => this.notifier.error('Error in video miniature component: ' + err.message)
+ )
}
}
+import { finalize } from 'rxjs/operators'
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
-import { AuthService } from '@app/core'
+import { AuthService, Notifier } from '@app/core'
import { VideoFilter, VideoSortField } from '@shared/models'
import { Video, VideoService } from '../../shared-main'
import { MiniatureDisplayOptions } from '../../shared-video-miniature'
constructor (
private auth: AuthService,
- private videoService: VideoService
+ private videoService: VideoService,
+ private notifier: Notifier
) { }
getUser () {
}
this.videoService.getVideos(options)
- .subscribe({
- next: ({ data }) => this.videos = data,
+ .pipe(finalize(() => this.loaded.emit(true)))
+ .subscribe(
+ ({ data }) => this.videos = data,
- complete: () => this.loaded.emit(true)
- })
+ err => this.notifier.error('Error in videos list component: ' + err.message)
+ )
}
}