diff options
author | Chocobozzz <me@florianbigard.com> | 2022-03-02 15:47:04 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-03-02 15:47:04 +0100 |
commit | 77f811ced1cdf85c48dcdfeeceb90807bce0c851 (patch) | |
tree | aeb8800d71cc7a67f8d5768e184df3874390cfa8 /client/src/app/helpers | |
parent | 42d73f1c57f131e33d632de55d2b231f3fafd70c (diff) | |
download | PeerTube-77f811ced1cdf85c48dcdfeeceb90807bce0c851.tar.gz PeerTube-77f811ced1cdf85c48dcdfeeceb90807bce0c851.tar.zst PeerTube-77f811ced1cdf85c48dcdfeeceb90807bce0c851.zip |
Fix channel avatar in select component
Diffstat (limited to 'client/src/app/helpers')
-rw-r--r-- | client/src/app/helpers/utils/channel.ts | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/client/src/app/helpers/utils/channel.ts b/client/src/app/helpers/utils/channel.ts index 094a844e0..83f36b70f 100644 --- a/client/src/app/helpers/utils/channel.ts +++ b/client/src/app/helpers/utils/channel.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | import { minBy } from 'lodash-es' | 1 | import { minBy } from 'lodash-es' |
2 | import { first, map } from 'rxjs/operators' | 2 | import { first, map } from 'rxjs/operators' |
3 | import { SelectChannelItem } from 'src/types/select-options-item.model' | 3 | import { SelectChannelItem } from 'src/types/select-options-item.model' |
4 | import { VideoChannel } from '@shared/models' | ||
4 | import { AuthService } from '../../core/auth' | 5 | import { AuthService } from '../../core/auth' |
5 | 6 | ||
6 | function listUserChannelsForSelect (authService: AuthService) { | 7 | function listUserChannelsForSelect (authService: AuthService) { |
@@ -24,7 +25,7 @@ function listUserChannelsForSelect (authService: AuthService) { | |||
24 | id: c.id, | 25 | id: c.id, |
25 | label: c.displayName, | 26 | label: c.displayName, |
26 | support: c.support, | 27 | support: c.support, |
27 | avatarPath: minBy(c.avatars, 'width')?.[0]?.path | 28 | avatarPath: getAvatarPath(c) |
28 | }) as SelectChannelItem) | 29 | }) as SelectChannelItem) |
29 | }) | 30 | }) |
30 | ) | 31 | ) |
@@ -33,3 +34,11 @@ function listUserChannelsForSelect (authService: AuthService) { | |||
33 | export { | 34 | export { |
34 | listUserChannelsForSelect | 35 | listUserChannelsForSelect |
35 | } | 36 | } |
37 | |||
38 | // --------------------------------------------------------------------------- | ||
39 | |||
40 | function getAvatarPath (c: VideoChannel) { | ||
41 | if (!c.avatars || c.avatars.length === 0) return undefined | ||
42 | |||
43 | return minBy(c.avatars, 'width').path | ||
44 | } | ||