Batch insertion of `shouldShareHistory`
This commit is contained in:
parent
0e504e9014
commit
6f384c799f
|
@ -384,6 +384,7 @@ internal class DefaultCryptoService @Inject constructor(
|
|||
}
|
||||
}
|
||||
}
|
||||
cryptoStore.onSyncWillProcess()
|
||||
}
|
||||
|
||||
private fun internalStart() {
|
||||
|
@ -432,6 +433,7 @@ internal class DefaultCryptoService @Inject constructor(
|
|||
* @param syncResponse the syncResponse
|
||||
*/
|
||||
fun onSyncCompleted(syncResponse: SyncResponse) {
|
||||
cryptoStore.onSyncCompleted()
|
||||
cryptoCoroutineScope.launch(coroutineDispatchers.crypto) {
|
||||
runCatching {
|
||||
if (syncResponse.deviceLists != null) {
|
||||
|
|
|
@ -48,6 +48,9 @@ import org.matrix.olm.OlmOutboundGroupSession
|
|||
*/
|
||||
internal interface IMXCryptoStore {
|
||||
|
||||
fun onSyncWillProcess()
|
||||
fun onSyncCompleted()
|
||||
|
||||
/**
|
||||
* @return the device id
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright (c) 2023 The Matrix.org Foundation C.I.C.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.matrix.android.sdk.internal.crypto.store.db
|
||||
|
||||
data class CryptoStoreAggregator(
|
||||
val setShouldShareHistoryData: MutableMap<String, Boolean> = mutableMapOf()
|
||||
)
|
|
@ -716,9 +716,7 @@ internal class RealmCryptoStore @Inject constructor(
|
|||
override fun setShouldShareHistory(roomId: String, shouldShareHistory: Boolean) {
|
||||
Timber.tag(loggerTag.value)
|
||||
.v("setShouldShareHistory for room $roomId is $shouldShareHistory")
|
||||
doRealmTransaction(realmConfiguration) {
|
||||
CryptoRoomEntity.getOrCreate(it, roomId).shouldShareHistory = shouldShareHistory
|
||||
}
|
||||
cryptoStoreAggregator?.setShouldShareHistoryData?.put(roomId, shouldShareHistory)
|
||||
}
|
||||
|
||||
override fun storeSession(olmSessionWrapper: OlmSessionWrapper, deviceKey: String) {
|
||||
|
@ -1815,4 +1813,26 @@ internal class RealmCryptoStore @Inject constructor(
|
|||
// Can we do something for WithHeldSessionEntity?
|
||||
}
|
||||
}
|
||||
|
||||
private var cryptoStoreAggregator: CryptoStoreAggregator? = null
|
||||
override fun onSyncWillProcess() {
|
||||
if (cryptoStoreAggregator != null) {
|
||||
Timber.e("cryptoStoreAggregator is not null...")
|
||||
}
|
||||
cryptoStoreAggregator = CryptoStoreAggregator()
|
||||
}
|
||||
|
||||
override fun onSyncCompleted() {
|
||||
val aggregator = cryptoStoreAggregator ?: return Unit.also {
|
||||
Timber.e("cryptoStoreAggregator is null...")
|
||||
}
|
||||
|
||||
doRealmTransaction("onSyncCompleted", realmConfiguration) { realm ->
|
||||
// setShouldShareHistory
|
||||
aggregator.setShouldShareHistoryData.map {
|
||||
CryptoRoomEntity.getOrCreate(realm, it.key).shouldShareHistory = it.value
|
||||
}
|
||||
}
|
||||
cryptoStoreAggregator = null
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue