forked from GitHub-Mirror/riotX-android
Fix case where heroes is empty (fallback to display name of loaded members)
This commit is contained in:
parent
f747d268c9
commit
88362edece
@ -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 New Issue
Block a user