+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
}