]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/helpers/utils/channel.ts
Translated using Weblate (Malayalam)
[github/Chocobozzz/PeerTube.git] / client / src / app / helpers / utils / channel.ts
CommitLineData
dd24f1bb
C
1import { first, map } from 'rxjs/operators'
2import { SelectChannelItem } from 'src/types/select-options-item.model'
3import { AuthService } from '../../core/auth'
4
5function listUserChannels (authService: AuthService) {
6 return authService.userInformationLoaded
7 .pipe(
8 first(),
9 map(() => {
10 const user = authService.getUser()
11 if (!user) return undefined
12
13 const videoChannels = user.videoChannels
14 if (Array.isArray(videoChannels) === false) return undefined
15
16 return videoChannels
17 .sort((a, b) => {
18 if (a.updatedAt < b.updatedAt) return 1
19 if (a.updatedAt > b.updatedAt) return -1
20 return 0
21 })
22 .map(c => ({
23 id: c.id,
24 label: c.displayName,
25 support: c.support,
26 avatarPath: c.avatar?.path
27 }) as SelectChannelItem)
28 })
29 )
30}
31
32export {
33 listUserChannels
34}