Skip to content

Instantly share code, notes, and snippets.

@tayfun
Created August 24, 2023 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tayfun/50d6329173a6699caec81b5196d87623 to your computer and use it in GitHub Desktop.
Save tayfun/50d6329173a6699caec81b5196d87623 to your computer and use it in GitHub Desktop.
sendbird custom channel preview override
import { useSendbirdStateContext } from "@sendbird/uikit-react";
import ChannelPreview from "@sendbird/uikit-react/ChannelList/components/ChannelPreview";
import SendbirdUIKitGlobal from 'SendbirdUIKitGlobal';
interface CustomChannelPreviewInterface extends SendbirdUIKitGlobal.ChannelPreviewInterface {
startupId: number;
}
const CustomChannelPreview = (props:CustomChannelPreviewInterface) => {
const {channel, startupId, ...restProps} = props;
const sbState = useSendbirdStateContext();
const currentUserId = sbState?.stores?.userStore?.user?.userId;
if (!channel.name || channel.name === "Group Channel") {
const defaultChannelTitle = (channel?.members || [])
.filter(({ userId }: {userId:string}) => userId !== currentUserId)
.map(({ nickname }: {nickname:string}) => (nickname || ""))
.join(', ');
const customChannelName = `${defaultChannelTitle} - Startup ${startupId}`;
channel.name = customChannelName;
}
return <ChannelPreview channel={channel} {...restProps} />;
};
export default CustomChannelPreview;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment