From 77f811ced1cdf85c48dcdfeeceb90807bce0c851 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 2 Mar 2022 15:47:04 +0100 Subject: [PATCH] Fix channel avatar in select component --- client/src/app/helpers/utils/channel.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 @@ 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 listUserChannelsForSelect (authService: AuthService) { @@ -24,7 +25,7 @@ function listUserChannelsForSelect (authService: AuthService) { id: c.id, label: c.displayName, support: c.support, - avatarPath: minBy(c.avatars, 'width')?.[0]?.path + avatarPath: getAvatarPath(c) }) as SelectChannelItem) }) ) @@ -33,3 +34,11 @@ function listUserChannelsForSelect (authService: AuthService) { export { listUserChannelsForSelect } + +// --------------------------------------------------------------------------- + +function getAvatarPath (c: VideoChannel) { + if (!c.avatars || c.avatars.length === 0) return undefined + + return minBy(c.avatars, 'width').path +}