From 02dc13e38d392e09bbb40fe845154558642a2af1 Mon Sep 17 00:00:00 2001 From: valere Date: Tue, 10 Jan 2023 16:48:39 +0100 Subject: [PATCH] Fix existing dm returning local room echo --- .../android/sdk/internal/session/room/RoomGetter.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomGetter.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomGetter.kt index e3f4732cc1..f45f2b8481 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomGetter.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomGetter.kt @@ -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 } }