mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-24 10:25:51 +03:00
Fix case where heroes is empty (fallback to display name of loaded members)
This commit is contained in:
parent
f747d268c9
commit
88362edece
1 changed files with 5 additions and 5 deletions
|
@ -5,20 +5,20 @@ import im.vector.matrix.android.api.session.room.model.RoomMember
|
|||
class RoomMemberDisplayNameResolver {
|
||||
|
||||
fun resolve(userId: String, members: Map<String, RoomMember>): String? {
|
||||
var displayName: String? = null
|
||||
val currentMember = members[userId]
|
||||
var displayName = currentMember?.displayName
|
||||
// Get the user display name from the member list of the room
|
||||
// Do not consider null display name
|
||||
|
||||
if (currentMember != null && !currentMember.displayName.isNullOrEmpty()) {
|
||||
val hasNameCollision = members
|
||||
.filterValues { it != currentMember && it.displayName == currentMember.displayName }
|
||||
.isNotEmpty()
|
||||
displayName = if (hasNameCollision) {
|
||||
"${currentMember.displayName} ( $userId )"
|
||||
} else {
|
||||
currentMember.displayName
|
||||
if (hasNameCollision) {
|
||||
displayName = "${currentMember.displayName} ( $userId )"
|
||||
}
|
||||
}
|
||||
|
||||
// TODO handle invited users
|
||||
/*else if (null != member && TextUtils.equals(member!!.membership, RoomMember.MEMBERSHIP_INVITE)) {
|
||||
val user = (mDataHandler as MXDataHandler).getUser(userId)
|
||||
|
|
Loading…
Reference in a new issue