Call: fix wrong opponent name

This commit is contained in:
ganfra 2021-08-18 10:51:03 +02:00
parent 3b1249c489
commit d3e4a3c010
1 changed files with 6 additions and 3 deletions

View File

@ -16,17 +16,20 @@
package im.vector.app.features.call.webrtc package im.vector.app.features.call.webrtc
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.util.MatrixItem import org.matrix.android.sdk.api.util.MatrixItem
import org.matrix.android.sdk.api.util.toMatrixItem import org.matrix.android.sdk.api.util.toMatrixItem
fun WebRtcCall.getOpponentAsMatrixItem(session: Session): MatrixItem? { fun WebRtcCall.getOpponentAsMatrixItem(session: Session): MatrixItem? {
return session.getRoomSummary(nativeRoomId)?.let { roomSummary -> return session.getRoom(nativeRoomId)?.let { room ->
val roomSummary = room.roomSummary() ?: return@let null
// Fallback to RoomSummary if there is no other member. // Fallback to RoomSummary if there is no other member.
if (roomSummary.otherMemberIds.isEmpty()) { if (roomSummary.otherMemberIds.isEmpty().orFalse()) {
roomSummary.toMatrixItem() roomSummary.toMatrixItem()
} else { } else {
roomSummary.otherMemberIds.first().let { session.getUser(it)?.toMatrixItem() } val userId = roomSummary.otherMemberIds.first()
return room.getRoomMember(userId)?.toMatrixItem()
} }
} }
} }