From 1315bb4f9aebd97c87ce297d3ce981524e4fde7d Mon Sep 17 00:00:00 2001 From: martincupela Date: Fri, 27 Nov 2026 11:40:37 +0100 Subject: [PATCH 1/4] fix: show an unnamed channel with the same title and avatar in every channel view A channel without a name looked different in each place: the channel list row took its avatar initial from the latest sender's user ID and showed an untranslated "N/A", while the channel header and channel details showed an empty title. - useChannelPreviewInfo().displayTitle falls back to the translated "Unnamed channel" (common.unnamedChannel.text). useChannelDisplayName is unchanged. - useChannelPreviewInfo also returns avatarName (the channel's name, or a DM's other member's name, never an ID or a placeholder) and isGroupChannel. The list row, the channel header and channel details use them: image, then group member tiles, then initials, then the person icon for a DM or the people icon for a group. - ChannelListItemUI takes optional avatarName (null shows the icon; left out, displayTitle is used as before) and isGroupChannel. - GroupAvatar takes FallbackIcon and passes it only to its single avatar. - New useThreadPreviewInfo gives ThreadHeader and ThreadListItemUI one title: the channel name, else the parent message author's name. The thread row's avatar no longer falls back to the latest reply author's user ID. - The tutorial and cookbook recipes use avatarName and useThreadPreviewInfo. Closes REACT-1630 --- .../channel-invites/Invitations.tsx | 15 +- .../channel-list/preview-ui/ChannelChip.tsx | 15 +- .../preview-ui/CompactChannelRow.tsx | 8 +- .../channel-header/CustomChannelHeader.tsx | 15 +- .../thread-header/CustomThreadHeader.tsx | 15 +- .../recipes/panels/threads-view/ThreadRow.tsx | 2 +- .../src/6-custom-ui-components/App.tsx | 8 +- src/components/Avatar/GroupAvatar.tsx | 8 + .../Avatar/__tests__/GroupAvatar.test.tsx | 21 ++ .../ChannelHeader/ChannelHeader.tsx | 14 +- .../__tests__/ChannelHeader.test.tsx | 7 + .../ChannelListItem/ChannelListItem.tsx | 21 +- .../ChannelListItem/ChannelListItemUI.tsx | 13 +- .../__tests__/ChannelListItemUI.test.tsx | 43 ++++ .../__tests__/channelTitle.test.tsx | 186 ++++++++++++++++++ .../ChannelListItem/channelDisplayState.ts | 19 ++ .../__tests__/useChannelPreviewInfo.test.tsx | 96 +++++++++ .../hooks/useChannelPreviewInfo.ts | 37 +++- src/components/ChannelListItem/utils.a11y.ts | 5 +- src/components/Thread/ThreadHeader.tsx | 27 +-- .../Thread/__tests__/ThreadHeader.test.tsx | 18 +- .../Threads/ThreadList/ThreadListItemUI.tsx | 19 +- .../__tests__/ThreadListItemUI.test.tsx | 29 ++- .../Threads/ThreadList/utils.a11y.ts | 2 +- .../__tests__/useThreadPreviewInfo.test.tsx | 143 ++++++++++++++ .../Threads/hooks/useThreadPreviewInfo.ts | 43 ++++ src/components/Threads/index.ts | 1 + src/i18n/__tests__/catalog.fixture.json | 1 + src/i18n/keys.ts | 1 + .../ChannelManagementView.tsx | 33 ++-- 30 files changed, 765 insertions(+), 100 deletions(-) create mode 100644 src/components/ChannelListItem/__tests__/channelTitle.test.tsx create mode 100644 src/components/Threads/hooks/__tests__/useThreadPreviewInfo.test.tsx create mode 100644 src/components/Threads/hooks/useThreadPreviewInfo.ts diff --git a/examples/cookbook/src/recipes/channel-list/channel-invites/Invitations.tsx b/examples/cookbook/src/recipes/channel-list/channel-invites/Invitations.tsx index a3a609b0fb..31ecd30459 100644 --- a/examples/cookbook/src/recipes/channel-list/channel-invites/Invitations.tsx +++ b/examples/cookbook/src/recipes/channel-list/channel-invites/Invitations.tsx @@ -7,6 +7,7 @@ import { useAriaLiveAnnouncer, useChannelPreviewInfo, useChatContext, + useComponentContextIcons, useStateStore, } from 'stream-chat-react'; import './Invitations.css'; @@ -42,9 +43,14 @@ const Invitation = ({ }) => { const { client } = useChatContext(); const announce = useAriaLiveAnnouncer(); - const { displayImage, displayTitle, groupChannelDisplayInfo } = useChannelPreviewInfo({ - channel, - }); + const { IconUsers } = useComponentContextIcons(); + const { + avatarName, + displayImage, + displayTitle, + groupChannelDisplayInfo, + isGroupChannel, + } = useChannelPreviewInfo({ channel }); const [answering, setAnswering] = useState(); const rowRef = useRef(null); const inviter = channel.data?.created_by?.name; @@ -87,9 +93,10 @@ const Invitation = ({