Extract dmUserStatus helper for DM user status resolution

This commit is contained in:
ganfra
2026-07-16 21:26:23 +02:00
parent 2152552daa
commit 3fdd6be832
3 changed files with 16 additions and 2 deletions
@@ -13,6 +13,7 @@ import io.element.android.libraries.designsystem.components.avatar.AvatarSize
import io.element.android.libraries.matrix.api.core.UserId
import io.element.android.libraries.matrix.api.room.RoomInfo
import io.element.android.libraries.matrix.api.room.RoomMember
import io.element.android.libraries.matrix.api.user.DisplayedStatus
fun RoomInfo.getAvatarData(size: AvatarSize) = AvatarData(
id = id.value,
@@ -45,3 +46,14 @@ fun RoomInfo.roleOf(userId: UserId): RoomMember.Role {
val powerLevel = powerLevelOf(userId = userId)
return RoomMember.Role.forPowerLevel(powerLevel)
}
/**
* Return the [DisplayedStatus] of the other member in a DM.
*/
fun RoomInfo.dmUserStatus(): DisplayedStatus? {
return if (isDm) {
heroes.firstOrNull()?.displayedStatus
} else {
null
}
}