import { Component, OnInit } from '@angular/core'
import { Router } from '@angular/router'
import { AuthService, Notifier, ServerService } from '@app/core'
-import { populateAsyncUserVideoChannels } from '@app/helpers'
+import { listUserChannels } from '@app/helpers'
import {
setPlaylistChannelValidator,
VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR,
setPlaylistChannelValidator(this.form.get('videoChannelId'), privacy)
})
- populateAsyncUserVideoChannels(this.authService, this.userVideoChannels)
- .catch(err => console.error('Cannot populate user video channels.', err))
+ listUserChannels(this.authService)
+ .subscribe(channels => this.userVideoChannels = channels)
this.serverService.getVideoPlaylistPrivacies()
.subscribe(videoPlaylistPrivacies => {
import { Component, OnDestroy, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
import { AuthService, Notifier, ServerService } from '@app/core'
-import { populateAsyncUserVideoChannels } from '@app/helpers'
+import { listUserChannels } from '@app/helpers'
import {
setPlaylistChannelValidator,
VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR,
setPlaylistChannelValidator(this.form.get('videoChannelId'), privacy)
})
- populateAsyncUserVideoChannels(this.authService, this.userVideoChannels)
- .catch(err => console.error('Cannot populate user video channels.', err))
+ listUserChannels(this.authService)
+ .subscribe(channels => this.userVideoChannels = channels)
this.paramsSub = this.route.params
.pipe(
import { SelectChannelItem } from 'src/types/select-options-item.model'
import { Directive, EventEmitter, OnInit } from '@angular/core'
import { AuthService, CanComponentDeactivateResult, Notifier, ServerService } from '@app/core'
-import { populateAsyncUserVideoChannels } from '@app/helpers'
+import { listUserChannels } from '@app/helpers'
import { FormReactive } from '@app/shared/shared-forms'
import { VideoCaptionEdit, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main'
import { LoadingBarService } from '@ngx-loading-bar/core'
ngOnInit () {
this.buildForm({})
- populateAsyncUserVideoChannels(this.authService, this.userVideoChannels)
- .then(() => this.firstStepChannelId = this.userVideoChannels[ 0 ].id)
+ listUserChannels(this.authService)
+ .subscribe(channels => {
+ this.userVideoChannels = channels
+ this.firstStepChannelId = this.userVideoChannels[0].id
+ })
this.serverConfig = this.serverService.getTmpConfig()
this.serverService.getConfig()
+import { map } from 'rxjs/operators'
import { SelectChannelItem } from 'src/types/select-options-item.model'
import { DatePipe } from '@angular/common'
import { HttpErrorResponse } from '@angular/common/http'
return decodeURIComponent(results[2].replace(/\+/g, ' '))
}
-function populateAsyncUserVideoChannels (
- authService: AuthService,
- channel: SelectChannelItem[]
-) {
- return new Promise<void>(res => {
- authService.userInformationLoaded
- .subscribe(
- () => {
- const user = authService.getUser()
- if (!user) return
-
- const videoChannels = user.videoChannels
- if (Array.isArray(videoChannels) === false) return
-
- videoChannels.forEach(c => channel.push({
- id: c.id,
- label: c.displayName,
- support: c.support,
- avatarPath: c.avatar?.path
- }))
-
- return res()
- }
- )
- })
+function listUserChannels (authService: AuthService) {
+ return authService.userInformationLoaded
+ .pipe(map(() => {
+ const user = authService.getUser()
+ if (!user) return undefined
+
+ const videoChannels = user.videoChannels
+ if (Array.isArray(videoChannels) === false) return undefined
+
+ return videoChannels.map(c => ({
+ id: c.id,
+ label: c.displayName,
+ support: c.support,
+ avatarPath: c.avatar?.path
+ }) as SelectChannelItem)
+ }))
}
function getAbsoluteAPIUrl () {
durationToString,
lineFeedToHtml,
getParameterByName,
- populateAsyncUserVideoChannels,
getAbsoluteAPIUrl,
dateToHuman,
immutableAssign,
scrollToTop,
isInViewport,
isXPercentInViewport,
+ listUserChannels,
uploadErrorHandler
}
'audio/x-flac': '.flac',
'audio/flac': '.flac',
'‎audio/aac': '.aac',
+ 'audio/m4a': '.m4a',
+ 'audio/x-m4a': '.m4a',
'audio/ac3': '.ac3'
},
EXT_MIMETYPE: null as { [ id: string ]: string }