Skip to content

Commit

Permalink
Reder proper user avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
JcMinarro committed Dec 3, 2024
1 parent c9f8887 commit 63c1ab6
Showing 1 changed file with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public fun SearchResultItem(
leadingContent: @Composable RowScope.(ItemState.SearchResultItemState) -> Unit = {
DefaultSearchResultItemLeadingContent(
searchResultItemState = it,
currentUser = currentUser,
)
},
centerContent: @Composable RowScope.(ItemState.SearchResultItemState) -> Unit = {
Expand Down Expand Up @@ -107,22 +108,31 @@ public fun SearchResultItem(
* the message.
*
* @param searchResultItemState The state of the search result item.
* @param currentUser The currently logged in user.
*/
@Composable
internal fun DefaultSearchResultItemLeadingContent(
searchResultItemState: ItemState.SearchResultItemState,
currentUser: User?,
) {
UserAvatar(
user = searchResultItemState.message.user,
modifier = Modifier
.padding(
start = ChatTheme.dimens.channelItemHorizontalPadding,
end = 4.dp,
top = ChatTheme.dimens.channelItemVerticalPadding,
bottom = ChatTheme.dimens.channelItemVerticalPadding,
(searchResultItemState
.channel
?.takeIf { it.members.size == 2 }
?.let { it.members.firstOrNull { it.getUserId() != currentUser?.id }?.user }
?: searchResultItemState.message.user)
.let { user ->
UserAvatar(
user = user,
modifier = Modifier
.padding(
start = ChatTheme.dimens.channelItemHorizontalPadding,
end = 4.dp,
top = ChatTheme.dimens.channelItemVerticalPadding,
bottom = ChatTheme.dimens.channelItemVerticalPadding,
)
.size(ChatTheme.dimens.channelAvatarSize),
)
.size(ChatTheme.dimens.channelAvatarSize),
)
}
}

/**
Expand Down

0 comments on commit 63c1ab6

Please sign in to comment.