From 9772bbe15722825883a59d0388c745e185e8087a Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 10 Jun 2019 16:58:48 +0200 Subject: [PATCH] Ganfra's review: revert change --- .../internal/database/RealmQueryLatch.kt | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/RealmQueryLatch.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/RealmQueryLatch.kt index 700f54c7..64afa3d4 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/RealmQueryLatch.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/RealmQueryLatch.kt @@ -35,20 +35,15 @@ class RealmQueryLatch(private val realmConfiguration: RealmConf val realm = Realm.getInstance(realmConfiguration) val result = realmQueryBuilder(realm).findAllAsync() - if (result.isEmpty()) { - result.addChangeListener(object : RealmChangeListener> { - override fun onChange(t: RealmResults) { - if (t.isNotEmpty()) { - result.removeChangeListener(this) - realm.close() - latch.countDown() - } + result.addChangeListener(object : RealmChangeListener> { + override fun onChange(t: RealmResults) { + if (t.isNotEmpty()) { + result.removeChangeListener(this) + realm.close() + latch.countDown() } - }) - } else { - realm.close() - latch.countDown() - } + } + }) } handler.post(runnable) latch.await()