Avoid useless transaction
This commit is contained in:
parent
a386a4762c
commit
f26178fc21
@ -19,4 +19,9 @@ package org.matrix.android.sdk.internal.crypto.store.db
|
|||||||
data class CryptoStoreAggregator(
|
data class CryptoStoreAggregator(
|
||||||
val setShouldShareHistoryData: MutableMap<String, Boolean> = mutableMapOf(),
|
val setShouldShareHistoryData: MutableMap<String, Boolean> = mutableMapOf(),
|
||||||
val setShouldEncryptForInvitedMembersData: MutableMap<String, Boolean> = mutableMapOf(),
|
val setShouldEncryptForInvitedMembersData: MutableMap<String, Boolean> = mutableMapOf(),
|
||||||
)
|
) {
|
||||||
|
fun isEmpty(): Boolean {
|
||||||
|
return setShouldShareHistoryData.isEmpty() &&
|
||||||
|
setShouldEncryptForInvitedMembersData.isEmpty()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1824,7 +1824,11 @@ internal class RealmCryptoStore @Inject constructor(
|
|||||||
val aggregator = cryptoStoreAggregator ?: return Unit.also {
|
val aggregator = cryptoStoreAggregator ?: return Unit.also {
|
||||||
Timber.e("cryptoStoreAggregator is null...")
|
Timber.e("cryptoStoreAggregator is null...")
|
||||||
}
|
}
|
||||||
|
cryptoStoreAggregator = null
|
||||||
|
|
||||||
|
if (aggregator.isEmpty()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
doRealmTransaction("onSyncCompleted", realmConfiguration) { realm ->
|
doRealmTransaction("onSyncCompleted", realmConfiguration) { realm ->
|
||||||
// setShouldShareHistory
|
// setShouldShareHistory
|
||||||
aggregator.setShouldShareHistoryData.map {
|
aggregator.setShouldShareHistoryData.map {
|
||||||
@ -1835,6 +1839,5 @@ internal class RealmCryptoStore @Inject constructor(
|
|||||||
CryptoRoomEntity.getOrCreate(realm, it.key).shouldEncryptForInvitedMembers = it.value
|
CryptoRoomEntity.getOrCreate(realm, it.key).shouldEncryptForInvitedMembers = it.value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cryptoStoreAggregator = null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user