mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 11:59:12 +03:00
Merge pull request #8396 from vector-im/feature/bma/fixCrashNoNetwork
Fix crash no network
This commit is contained in:
commit
37149c655e
8 changed files with 20 additions and 17 deletions
|
@ -8,8 +8,7 @@
|
|||
</value>
|
||||
</option>
|
||||
<option name="ALIGN_IN_COLUMNS_CASE_BRANCH" value="true" />
|
||||
<option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="2147483647" />
|
||||
<option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="2147483647" />
|
||||
<option name="LINE_BREAK_AFTER_MULTILINE_WHEN_ENTRY" value="false" />
|
||||
<option name="CONTINUATION_INDENT_IN_PARAMETER_LISTS" value="true" />
|
||||
<option name="CONTINUATION_INDENT_IN_ARGUMENT_LISTS" value="true" />
|
||||
<option name="CONTINUATION_INDENT_FOR_EXPRESSION_BODIES" value="true" />
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
|
@ -196,9 +196,7 @@ internal class RustCryptoService @Inject constructor(
|
|||
override suspend fun fetchDevicesList(): List<DeviceInfo> {
|
||||
val devicesList: List<DeviceInfo>
|
||||
withContext(coroutineDispatchers.io) {
|
||||
devicesList = tryOrNull {
|
||||
getDevicesTask.execute(Unit).devices
|
||||
}.orEmpty()
|
||||
devicesList = getDevicesTask.execute(Unit).devices.orEmpty()
|
||||
cryptoStore.saveMyDevicesInfo(devicesList)
|
||||
}
|
||||
return devicesList
|
||||
|
@ -247,7 +245,7 @@ internal class RustCryptoService @Inject constructor(
|
|||
cryptoCoroutineScope.launch(coroutineDispatchers.io) {
|
||||
cryptoStore.open()
|
||||
// Just update
|
||||
fetchDevicesList()
|
||||
tryOrNull { fetchDevicesList() }
|
||||
cryptoStore.tidyUpDataBase()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import kotlinx.coroutines.flow.onEach
|
|||
import kotlinx.coroutines.flow.sample
|
||||
import kotlinx.coroutines.launch
|
||||
import org.matrix.android.sdk.api.extensions.orFalse
|
||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo
|
||||
import org.matrix.android.sdk.api.session.getUserOrDefault
|
||||
|
@ -101,7 +102,7 @@ class UnknownDeviceDetectorSharedViewModel @AssistedInject constructor(
|
|||
session.flow().liveUserCryptoDevices(session.myUserId),
|
||||
session.flow().liveMyDevicesInfo(),
|
||||
session.flow().liveCrossSigningPrivateKeys(),
|
||||
) { cryptoList, infoList, pInfo ->
|
||||
) { cryptoList, infoList, pInfo ->
|
||||
Timber.v("## Detector trigger ${cryptoList.map { "${it.deviceId} ${it.trustLevel}" }}")
|
||||
Timber.v("## Detector trigger canCrossSign ${pInfo.get().selfSigned != null}")
|
||||
|
||||
|
@ -146,13 +147,13 @@ class UnknownDeviceDetectorSharedViewModel @AssistedInject constructor(
|
|||
.sample(5_000)
|
||||
.onEach {
|
||||
// If we have a new crypto device change, we might want to trigger refresh of device info
|
||||
session.cryptoService().fetchDevicesList()
|
||||
tryOrNull { session.cryptoService().fetchDevicesList() }
|
||||
}
|
||||
.launchIn(viewModelScope)
|
||||
|
||||
// trigger a refresh of lastSeen / last Ip
|
||||
viewModelScope.launch {
|
||||
session.cryptoService().fetchDevicesList()
|
||||
tryOrNull { session.cryptoService().fetchDevicesList() }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ import kotlinx.coroutines.launch
|
|||
import kotlinx.coroutines.withContext
|
||||
import me.gujun.android.span.span
|
||||
import org.matrix.android.sdk.api.extensions.getFingerprintHumanReadable
|
||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||
import org.matrix.android.sdk.api.raw.RawService
|
||||
import org.matrix.android.sdk.api.session.crypto.crosssigning.isVerified
|
||||
import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo
|
||||
|
@ -646,9 +647,11 @@ class VectorSettingsSecurityPrivacyFragment :
|
|||
}
|
||||
}
|
||||
// TODO Move to a ViewModel...
|
||||
val devicesList = session.cryptoService().fetchDevicesList()
|
||||
withContext(Dispatchers.Main) {
|
||||
refreshCryptographyPreference(devicesList)
|
||||
val devicesList = tryOrNull { session.cryptoService().fetchDevicesList() }
|
||||
devicesList?.let {
|
||||
withContext(Dispatchers.Main) {
|
||||
refreshCryptographyPreference(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ import org.matrix.android.sdk.api.auth.data.LoginFlowTypes
|
|||
import org.matrix.android.sdk.api.auth.registration.RegistrationFlowResponse
|
||||
import org.matrix.android.sdk.api.auth.registration.nextUncompletedStage
|
||||
import org.matrix.android.sdk.api.extensions.orFalse
|
||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||
import org.matrix.android.sdk.api.failure.Failure
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
|
||||
|
@ -190,7 +191,7 @@ class DevicesViewModel @AssistedInject constructor(
|
|||
.sample(5_000)
|
||||
.onEach {
|
||||
// If we have a new crypto device change, we might want to trigger refresh of device info
|
||||
session.cryptoService().fetchDevicesList()
|
||||
tryOrNull { session.cryptoService().fetchDevicesList() }
|
||||
}
|
||||
.launchIn(viewModelScope)
|
||||
|
||||
|
@ -203,7 +204,7 @@ class DevicesViewModel @AssistedInject constructor(
|
|||
|
||||
refreshSource.stream().throttleFirst(4_000)
|
||||
.onEach {
|
||||
session.cryptoService().fetchDevicesList()
|
||||
tryOrNull { session.cryptoService().fetchDevicesList() }
|
||||
session.cryptoService().downloadKeysIfNeeded(listOf(session.myUserId), true)
|
||||
}
|
||||
.launchIn(viewModelScope)
|
||||
|
|
|
@ -22,6 +22,7 @@ import kotlinx.coroutines.flow.distinctUntilChanged
|
|||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.flow.sample
|
||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||
import org.matrix.android.sdk.flow.flow
|
||||
import javax.inject.Inject
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
@ -40,7 +41,7 @@ class RefreshDevicesOnCryptoDevicesChangeUseCase @Inject constructor(
|
|||
.sample(samplingPeriodMs)
|
||||
.onEach {
|
||||
// If we have a new crypto device change, we might want to trigger refresh of device info
|
||||
session.cryptoService().fetchDevicesList()
|
||||
tryOrNull { session.cryptoService().fetchDevicesList() }
|
||||
}
|
||||
.collect()
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package im.vector.app.features.settings.devices.v2
|
||||
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||
import javax.inject.Inject
|
||||
|
||||
class RefreshDevicesUseCase @Inject constructor(
|
||||
|
@ -24,7 +25,7 @@ class RefreshDevicesUseCase @Inject constructor(
|
|||
) {
|
||||
suspend fun execute() {
|
||||
activeSessionHolder.getSafeActiveSession()?.let { session ->
|
||||
session.cryptoService().fetchDevicesList()
|
||||
tryOrNull { session.cryptoService().fetchDevicesList() }
|
||||
session.cryptoService().downloadKeysIfNeeded(listOf(session.myUserId), true)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue