Fix existing dm returning local room echo

This commit is contained in:
valere 2023-01-10 16:48:39 +01:00
parent 56b1b9dec1
commit 02dc13e38d

View file

@ -19,6 +19,7 @@ package org.matrix.android.sdk.internal.session.room
import io.realm.Realm
import org.matrix.android.sdk.api.session.room.Room
import org.matrix.android.sdk.api.session.room.model.Membership
import org.matrix.android.sdk.api.session.room.model.localecho.RoomLocalEcho
import org.matrix.android.sdk.internal.database.RealmSessionProvider
import org.matrix.android.sdk.internal.database.model.RoomEntity
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
@ -51,7 +52,12 @@ internal class DefaultRoomGetter @Inject constructor(
.equalTo(RoomSummaryEntityFields.IS_DIRECT, true)
.equalTo(RoomSummaryEntityFields.MEMBERSHIP_STR, Membership.JOIN.name)
.findAll()
.firstOrNull { dm -> dm.otherMemberIds.size == 1 && dm.otherMemberIds.first(null) == otherUserId }
.firstOrNull { dm ->
// deferred DM could create local echo of summaries
!RoomLocalEcho.isLocalEchoId(dm.roomId) &&
dm.otherMemberIds.size == 1 &&
dm.otherMemberIds.first(null) == otherUserId
}
?.roomId
}
}