mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-23 01:45:52 +03:00
Improve room name for invitation
This commit is contained in:
parent
2df8eb199b
commit
bd14c77ff0
2 changed files with 11 additions and 9 deletions
|
@ -39,5 +39,7 @@ internal open class RoomMemberSummaryEntity(@PrimaryKey var primaryKey: String =
|
|||
membershipStr = value.name
|
||||
}
|
||||
|
||||
fun getBestName() = displayName?.takeIf { it.isNotBlank() } ?: userId
|
||||
|
||||
companion object
|
||||
}
|
||||
|
|
|
@ -77,14 +77,14 @@ internal class RoomDisplayNameResolver @Inject constructor(
|
|||
if (roomEntity?.membership == Membership.INVITE) {
|
||||
val inviteMeEvent = roomMembers.getLastStateEvent(userId)
|
||||
val inviterId = inviteMeEvent?.sender
|
||||
name = if (inviterId != null) {
|
||||
activeMembers.where()
|
||||
.equalTo(RoomMemberSummaryEntityFields.USER_ID, inviterId)
|
||||
.findFirst()
|
||||
?.displayName
|
||||
} else {
|
||||
roomDisplayNameFallbackProvider.getNameForRoomInvite()
|
||||
}
|
||||
name = inviterId
|
||||
?.let {
|
||||
activeMembers.where()
|
||||
.equalTo(RoomMemberSummaryEntityFields.USER_ID, it)
|
||||
.findFirst()
|
||||
?.getBestName()
|
||||
}
|
||||
?: roomDisplayNameFallbackProvider.getNameForRoomInvite()
|
||||
} else if (roomEntity?.membership == Membership.JOIN) {
|
||||
val roomSummary = RoomSummaryEntity.where(realm, roomId).findFirst()
|
||||
val invitedCount = roomSummary?.invitedMembersCount ?: 0
|
||||
|
@ -150,7 +150,7 @@ internal class RoomDisplayNameResolver @Inject constructor(
|
|||
if (roomMemberSummary == null) return null
|
||||
val isUnique = roomMemberHelper.isUniqueDisplayName(roomMemberSummary.displayName)
|
||||
return if (isUnique) {
|
||||
roomMemberSummary.displayName
|
||||
roomMemberSummary.getBestName()
|
||||
} else {
|
||||
"${roomMemberSummary.displayName} (${roomMemberSummary.userId})"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue