diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomMemberDisplayNameResolver.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomMemberDisplayNameResolver.kt index f16490dd..56f39761 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomMemberDisplayNameResolver.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomMemberDisplayNameResolver.kt @@ -5,20 +5,20 @@ import im.vector.matrix.android.api.session.room.model.RoomMember class RoomMemberDisplayNameResolver { fun resolve(userId: String, members: Map): 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)