Merge pull request #5792 from vector-im/bugfix/eric/realm-write-async

Replaces monarchy.doWithRealm with monarchy.awaitTransaction
This commit is contained in:
Adam Brown 2022-04-20 12:48:05 +01:00 committed by GitHub
commit 7c7822a28a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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.UserEntityFactory
import org.matrix.android.sdk.internal.session.user.accountdata.DirectChatsHelper 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.session.user.accountdata.UpdateUserAccountDataTask
import org.matrix.android.sdk.internal.util.awaitTransaction
import javax.inject.Inject import javax.inject.Inject
internal class SyncResponsePostTreatmentAggregatorHandler @Inject constructor( internal class SyncResponsePostTreatmentAggregatorHandler @Inject constructor(
@ -91,9 +92,9 @@ internal class SyncResponsePostTreatmentAggregatorHandler @Inject constructor(
} }
} }
private fun List<User>.saveLocally() { private suspend fun List<User>.saveLocally() {
val userEntities = map { user -> UserEntityFactory.create(user) } val userEntities = map { user -> UserEntityFactory.create(user) }
monarchy.doWithRealm { monarchy.awaitTransaction {
it.insertOrUpdate(userEntities) it.insertOrUpdate(userEntities)
} }
} }