Fix unhandled crashes when network is not reacheable.

This commit is contained in:
Benoit Marty 2023-06-15 14:31:49 +02:00
parent 2a5df54ae4
commit 8433e222ad
2 changed files with 6 additions and 2 deletions

View File

@ -19,6 +19,7 @@ package org.matrix.android.sdk.internal.session.sync.handler
import androidx.work.BackoffPolicy
import androidx.work.ExistingWorkPolicy
import org.matrix.android.sdk.api.MatrixPatterns
import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.internal.crypto.crosssigning.UpdateTrustWorker
import org.matrix.android.sdk.internal.crypto.crosssigning.UpdateTrustWorkerDataRepository
import org.matrix.android.sdk.internal.di.SessionId
@ -81,9 +82,11 @@ internal class SyncResponsePostTreatmentAggregatorHandler @Inject constructor(
}
}
if (hasUpdate) {
tryOrNull("Unable to update user account data") {
updateUserAccountDataTask.execute(UpdateUserAccountDataTask.DirectChatParams(directMessages = directChats))
}
}
}
private fun fetchAndUpdateUsers(userIdsToFetch: Collection<String>) {
if (userIdsToFetch.isEmpty()) return

View File

@ -20,6 +20,7 @@ import com.zhuinden.monarchy.Monarchy
import io.realm.Realm
import io.realm.RealmList
import io.realm.kotlin.where
import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.api.failure.GlobalError
import org.matrix.android.sdk.api.failure.InitialSyncRequestReason
import org.matrix.android.sdk.api.session.accountdata.UserAccountDataEvent
@ -122,7 +123,7 @@ internal class UserAccountDataSyncHandler @Inject constructor(
val updateUserAccountParams = UpdateUserAccountDataTask.DirectChatParams(
directMessages = directChats
)
updateUserAccountDataTask.execute(updateUserAccountParams)
tryOrNull("Unable to update user account data") { updateUserAccountDataTask.execute(updateUserAccountParams) }
}
}