Should fix issue with DM creation where we can ends up with DM in rooms

This commit is contained in:
ganfra 2021-06-03 19:33:28 +02:00
parent d520dfe108
commit 1b8b59076c

View File

@ -31,9 +31,11 @@ internal class DirectChatsHelper @Inject constructor(@SessionDatabase
*/ */
fun getLocalUserAccount(filterRoomId: String? = null): MutableMap<String, MutableList<String>> { fun getLocalUserAccount(filterRoomId: String? = null): MutableMap<String, MutableList<String>> {
return Realm.getInstance(realmConfiguration).use { realm -> 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) RoomSummaryEntity.getDirectRooms(realm)
.asSequence() .asSequence()
.filter { it.roomId != filterRoomId && it.directUserId != null } .filter { it.roomId != filterRoomId && it.directUserId != null && it.membership.isActive() }
.groupByTo(mutableMapOf(), { it.directUserId!! }, { it.roomId }) .groupByTo(mutableMapOf(), { it.directUserId!! }, { it.roomId })
} }
} }