findAll() does not return null value

This commit is contained in:
Benoit Marty 2020-02-07 14:30:44 +01:00
parent 9aadbbc3c7
commit 34c5f37bbc
2 changed files with 8 additions and 8 deletions

View File

@ -110,7 +110,9 @@ internal class ShieldTrustUpdater @Inject constructor(
val map = HashMap<String, List<String>>()
impactedRoomsId.forEach { roomId ->
RoomMemberSummaryEntity.where(backgroundSessionRealm.get(), roomId).findAll()?.let { results ->
RoomMemberSummaryEntity.where(backgroundSessionRealm.get(), roomId)
.findAll()
.let { results ->
map[roomId] = results.map { it.userId }
}
}

View File

@ -54,13 +54,11 @@ internal class DefaultRoomGetter @Inject constructor(
Realm.getInstance(monarchy.realmConfiguration).use { realm ->
val candidates = RoomSummaryEntity.where(realm)
.equalTo(RoomSummaryEntityFields.IS_DIRECT, true)
.findAll()?.filter { dm ->
.findAll()
.filter { dm ->
dm.otherMemberIds.contains(otherUserId)
&& dm.membership == Membership.JOIN
}?.map {
it.roomId
}
?: return null
}.map { it.roomId }
candidates.forEach { roomId ->
if (RoomMemberHelper(realm, roomId).getActiveRoomMemberIds().any { it == otherUserId }) {
return RoomEntity.where(realm, roomId).findFirst()?.let { roomFactory.create(roomId) }