Skip to content

Commit

Permalink
Avoid useless transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarty committed Jan 3, 2023
1 parent a386a47 commit f26178f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -1835,6 +1839,5 @@ internal class RealmCryptoStore @Inject constructor(
CryptoRoomEntity.getOrCreate(realm, it.key).shouldEncryptForInvitedMembers = it.value
}
}
cryptoStoreAggregator = null
}
}

0 comments on commit f26178f

Please sign in to comment.