aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/helpers/utils/channel.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-08-19 09:24:29 +0200
committerChocobozzz <me@florianbigard.com>2021-08-25 11:24:11 +0200
commitdd24f1bb0a4b252e5342b251ba36853364da7b8e (patch)
tree41a9506d07413f056fb90425705e258f96fdc77d /client/src/app/helpers/utils/channel.ts
parent2e80d256cc75b4b02c8efc3d3e4cdf57ddf401a8 (diff)
downloadPeerTube-dd24f1bb0a4b252e5342b251ba36853364da7b8e.tar.gz
PeerTube-dd24f1bb0a4b252e5342b251ba36853364da7b8e.tar.zst
PeerTube-dd24f1bb0a4b252e5342b251ba36853364da7b8e.zip
Add video filters to common video pages
Diffstat (limited to 'client/src/app/helpers/utils/channel.ts')
-rw-r--r--client/src/app/helpers/utils/channel.ts34
1 files changed, 34 insertions, 0 deletions
diff --git a/client/src/app/helpers/utils/channel.ts b/client/src/app/helpers/utils/channel.ts
new file mode 100644
index 000000000..93863a8af
--- /dev/null
+++ b/client/src/app/helpers/utils/channel.ts
@@ -0,0 +1,34 @@
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}