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