1- import React from 'react' ;
1+ import React , { useMemo } from 'react' ;
22
33import { Channel , UserResponse } from 'stream-chat' ;
44
@@ -19,9 +19,8 @@ export type ChannelAvatarProps = {
1919
2020export const ChannelAvatar = ( props : ChannelAvatarProps ) => {
2121 const { channel } = props ;
22- const members = Object . values ( channel . state . members ) ;
2322 const online = useChannelPreviewDisplayPresence ( channel ) ;
24- const { showOnlineIndicator = online } = props ;
23+ const { showOnlineIndicator = online , size , showBorder = true } = props ;
2524
2625 const {
2726 theme : { semantics } ,
@@ -31,17 +30,16 @@ export const ChannelAvatar = (props: ChannelAvatarProps) => {
3130 const index = ( ( hashedValue % 5 ) + 1 ) as 1 | 2 | 3 | 4 | 5 ;
3231 const avatarBackgroundColor = semantics [ `avatarPaletteBg${ index } ` ] ;
3332
34- const { size , showBorder = true } = props ;
33+ const channelImage = channel . data ?. image ;
3534
36- const channelImage = undefined ;
35+ const usersForGroup = useMemo (
36+ ( ) => Object . values ( channel . state . members ) . map ( ( member ) => member . user as UserResponse ) ,
37+ [ channel . state . members ] ,
38+ ) ;
3739
3840 if ( ! channelImage ) {
3941 return (
40- < UserAvatarGroup
41- size = 'lg'
42- users = { members . map ( ( member ) => member . user as UserResponse ) }
43- showOnlineIndicator = { showOnlineIndicator }
44- />
42+ < UserAvatarGroup size = 'lg' users = { usersForGroup } showOnlineIndicator = { showOnlineIndicator } />
4543 ) ;
4644 }
4745
0 commit comments