From 1b8b59076c84f8f8011ffb13c27cbc8c77730e6c Mon Sep 17 00:00:00 2001 From: ganfra Date: Thu, 3 Jun 2021 19:33:28 +0200 Subject: [PATCH] Should fix issue with DM creation where we can ends up with DM in rooms --- .../internal/session/user/accountdata/DirectChatsHelper.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/DirectChatsHelper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/DirectChatsHelper.kt index e297f59b96..a9e5089774 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/DirectChatsHelper.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/DirectChatsHelper.kt @@ -31,9 +31,11 @@ internal class DirectChatsHelper @Inject constructor(@SessionDatabase */ fun getLocalUserAccount(filterRoomId: String? = null): MutableMap> { return Realm.getInstance(realmConfiguration).use { realm -> + // Makes sure we have the latest realm updates, this is important as we sent this information to the server. + realm.refresh() RoomSummaryEntity.getDirectRooms(realm) .asSequence() - .filter { it.roomId != filterRoomId && it.directUserId != null } + .filter { it.roomId != filterRoomId && it.directUserId != null && it.membership.isActive() } .groupByTo(mutableMapOf(), { it.directUserId!! }, { it.roomId }) } }