Avoid useless transaction

This commit is contained in:
Benoit Marty 2023-01-03 15:21:03 +01:00
parent a386a4762c
commit f26178fc21
2 changed files with 10 additions and 2 deletions

View File

@ -19,4 +19,9 @@ package org.matrix.android.sdk.internal.crypto.store.db
data class CryptoStoreAggregator(
val setShouldShareHistoryData: MutableMap<String, Boolean> = mutableMapOf(),
val setShouldEncryptForInvitedMembersData: MutableMap<String, Boolean> = mutableMapOf(),
)
) {
fun isEmpty(): Boolean {
return setShouldShareHistoryData.isEmpty() &&
setShouldEncryptForInvitedMembersData.isEmpty()
}
}

View File

@ -1824,7 +1824,11 @@ internal class RealmCryptoStore @Inject constructor(
val aggregator = cryptoStoreAggregator ?: return Unit.also {
Timber.e("cryptoStoreAggregator is null...")
}
cryptoStoreAggregator = null
if (aggregator.isEmpty()) {
return
}
doRealmTransaction("onSyncCompleted", realmConfiguration) { realm ->
// setShouldShareHistory
aggregator.setShouldShareHistoryData.map {
@ -1835,6 +1839,5 @@ internal class RealmCryptoStore @Inject constructor(
CryptoRoomEntity.getOrCreate(realm, it.key).shouldEncryptForInvitedMembers = it.value
}
}
cryptoStoreAggregator = null
}
}