]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/helpers/utils/channel.ts
Merge branch 'release/4.1.0' into develop
[github/Chocobozzz/PeerTube.git] / client / src / app / helpers / utils / channel.ts
index 93863a8afcca7203975b105019a36e64c43330ed..83f36b70ff15d145f8b1280c635a5ba58f1c7029 100644 (file)
@@ -1,8 +1,10 @@
+import { minBy } from 'lodash-es'
 import { first, map } from 'rxjs/operators'
 import { SelectChannelItem } from 'src/types/select-options-item.model'
+import { VideoChannel } from '@shared/models'
 import { AuthService } from '../../core/auth'
 
-function listUserChannels (authService: AuthService) {
+function listUserChannelsForSelect (authService: AuthService) {
   return authService.userInformationLoaded
     .pipe(
       first(),
@@ -23,12 +25,20 @@ function listUserChannels (authService: AuthService) {
             id: c.id,
             label: c.displayName,
             support: c.support,
-            avatarPath: c.avatar?.path
+            avatarPath: getAvatarPath(c)
           }) as SelectChannelItem)
       })
     )
 }
 
 export {
-  listUserChannels
+  listUserChannelsForSelect
+}
+
+// ---------------------------------------------------------------------------
+
+function getAvatarPath (c: VideoChannel) {
+  if (!c.avatars || c.avatars.length === 0) return undefined
+
+  return minBy(c.avatars, 'width').path
 }