From 90b063f0de921232a252d6ae7708431495aa5643 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Wed, 20 Apr 2022 10:55:06 +0200 Subject: [PATCH 1/2] Replaces doWithRealm with writeAsync --- .../sync/handler/SyncResponsePostTreatmentAggregatorHandler.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/SyncResponsePostTreatmentAggregatorHandler.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/SyncResponsePostTreatmentAggregatorHandler.kt index 25de05602a8..ed8f88dfdd6 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/SyncResponsePostTreatmentAggregatorHandler.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/SyncResponsePostTreatmentAggregatorHandler.kt @@ -93,7 +93,7 @@ internal class SyncResponsePostTreatmentAggregatorHandler @Inject constructor( private fun List.saveLocally() { val userEntities = map { user -> UserEntityFactory.create(user) } - monarchy.doWithRealm { + monarchy.writeAsync { it.insertOrUpdate(userEntities) } } From 8eab24c53dd2f641fc660d03d338c0565e77f752 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Wed, 20 Apr 2022 11:10:01 +0200 Subject: [PATCH 2/2] Replaces writeAsync with awaitTransaction --- .../handler/SyncResponsePostTreatmentAggregatorHandler.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/SyncResponsePostTreatmentAggregatorHandler.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/SyncResponsePostTreatmentAggregatorHandler.kt index ed8f88dfdd6..c638ed4f808 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/SyncResponsePostTreatmentAggregatorHandler.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/SyncResponsePostTreatmentAggregatorHandler.kt @@ -28,6 +28,7 @@ import org.matrix.android.sdk.internal.session.sync.model.accountdata.toMutable import org.matrix.android.sdk.internal.session.user.UserEntityFactory import org.matrix.android.sdk.internal.session.user.accountdata.DirectChatsHelper import org.matrix.android.sdk.internal.session.user.accountdata.UpdateUserAccountDataTask +import org.matrix.android.sdk.internal.util.awaitTransaction import javax.inject.Inject internal class SyncResponsePostTreatmentAggregatorHandler @Inject constructor( @@ -91,9 +92,9 @@ internal class SyncResponsePostTreatmentAggregatorHandler @Inject constructor( } } - private fun List.saveLocally() { + private suspend fun List.saveLocally() { val userEntities = map { user -> UserEntityFactory.create(user) } - monarchy.writeAsync { + monarchy.awaitTransaction { it.insertOrUpdate(userEntities) } }