Skip to content

Commit

Permalink
show group creator name in the last message text when a group is crea…
Browse files Browse the repository at this point in the history
…ted and there are no messages yet
  • Loading branch information
roienatan committed Dec 13, 2023
1 parent 54b6c9a commit 3beeb11
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/pages/inbox/components/ChatChannelItem/ChatChannelItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ export const ChatChannelItem: FC<ChatChannelFeedLayoutItemProps> = (props) => {
const isTabletView = useIsTabletView();
const {
fetchUsers: fetchDMUsers,
data: dmUsers,
loading,
fetched,
data: dmUsers, // dm users not including the current user.
} = useUsersByIds();
const {
data: chatChannelUserStatus,
Expand All @@ -50,6 +48,11 @@ export const ChatChannelItem: FC<ChatChannelFeedLayoutItemProps> = (props) => {

const dmUsersNames = dmUsers?.map((user) => getUserName(user));
const finalTitle = join(dmUsersNames, " & ");
const groupChatCreatorName = getUserName(
chatChannel.createdBy === user?.uid
? user
: dmUsers?.find((user) => user.uid === chatChannel.createdBy),
);

const handleOpenChat = useCallback(() => {
setChatItem({
Expand Down Expand Up @@ -146,7 +149,7 @@ export const ChatChannelItem: FC<ChatChannelFeedLayoutItemProps> = (props) => {
isImageRounded
dmUserIds={dmUserIds}
groupMessage={groupMessage}
createdBy={chatChannel.createdBy} // TODO: need to fetch createdBy user name. Check first if it's the current user since we have info already.
createdBy={groupChatCreatorName}
/>
);
};

0 comments on commit 3beeb11

Please sign in to comment.