Skip to content

Commit

Permalink
Merge pull request #4274 from tloncorp/ja/fix-bare-patp-chatlist
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesacklin authored Dec 10, 2024
2 parents 0d77230 + 89e58a3 commit 0f81015
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/ui/src/components/ListItem/ChannelListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ export function ChannelListItem({
<ListItem.Title dimmed={dimmed}>{title}</ListItem.Title>
{customSubtitle ? (
<ListItem.Subtitle>{customSubtitle}</ListItem.Subtitle>
) : (
) : (model.type === 'dm' || model.type === 'groupDm') &&
utils.hasNickname(model.members?.[0]?.contact) ? (
<ListItem.SubtitleWithIcon icon={subtitleIcon}>
{subtitle}
</ListItem.SubtitleWithIcon>
)}
) : null}
{model.lastPost && !model.isDmInvite && (
<ListItem.PostPreview
post={model.lastPost}
Expand Down
6 changes: 5 additions & 1 deletion packages/ui/src/utils/channelUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function getChannelMemberName(
if (disableNicknames) {
return member.contactId;
}
return member.contact?.nickname ?? member.contactId;
return member.contact?.nickname || member.contactId;
}

export function useChannelMemberName(member: db.ChatMember) {
Expand Down Expand Up @@ -111,3 +111,7 @@ export function getChannelTypeIcon(type: db.Channel['type']): IconType {
return 'ChannelTalk';
}
}

export function hasNickname(contact: db.Contact | null | undefined): boolean {
return 'nickname' in (contact ?? {}) && (contact?.nickname?.length ?? 0) > 0;
}

0 comments on commit 0f81015

Please sign in to comment.