do not launch in constructor

This commit is contained in:
valere 2023-04-14 16:48:24 +02:00
parent ca8dc37012
commit 4d9596b56e
2 changed files with 8 additions and 2 deletions

View File

@ -340,6 +340,10 @@ internal class DefaultCryptoService @Inject constructor(
uploadDeviceKeys()
}
tryOrNull {
deviceListManager.recover()
}
oneTimeKeysUploader.maybeUploadOneTimeKeys()
// this can throw if no backup
tryOrNull {

View File

@ -19,6 +19,7 @@ package org.matrix.android.sdk.internal.crypto
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.matrix.android.sdk.api.MatrixConfiguration
import org.matrix.android.sdk.api.MatrixCoroutineDispatchers
import org.matrix.android.sdk.api.MatrixPatterns
@ -93,8 +94,9 @@ internal class DeviceListManager @Inject constructor(
private val cryptoCoroutineContext = coroutineDispatchers.crypto
init {
cryptoCoroutineScope.launch(cryptoCoroutineContext) {
// Reset in progress status in case of restart
suspend fun recover() {
withContext(cryptoCoroutineContext) {
var isUpdated = false
val deviceTrackingStatuses = cryptoStore.getDeviceTrackingStatuses().toMutableMap()
for ((userId, status) in deviceTrackingStatuses) {