Crashes when private key missing

This commit is contained in:
Valere 2020-05-06 18:11:11 +02:00
parent 4306cb7812
commit da68212255
2 changed files with 10 additions and 4 deletions

View File

@ -8,7 +8,7 @@ Improvements 🙌:
- -
Bugfix 🐛: Bugfix 🐛:
- - Fix | Verify Manually by Text crashes if private SSK not known (#1337)
Translations 🗣: Translations 🗣:
- -

View File

@ -30,7 +30,6 @@ import com.squareup.inject.assisted.Assisted
import com.squareup.inject.assisted.AssistedInject import com.squareup.inject.assisted.AssistedInject
import im.vector.matrix.android.api.MatrixCallback import im.vector.matrix.android.api.MatrixCallback
import im.vector.matrix.android.api.NoOpMatrixCallback import im.vector.matrix.android.api.NoOpMatrixCallback
import im.vector.matrix.android.api.extensions.tryThis
import im.vector.matrix.android.api.failure.Failure import im.vector.matrix.android.api.failure.Failure
import im.vector.matrix.android.api.session.Session import im.vector.matrix.android.api.session.Session
import im.vector.matrix.android.api.session.crypto.verification.VerificationMethod import im.vector.matrix.android.api.session.crypto.verification.VerificationMethod
@ -48,6 +47,7 @@ import io.reactivex.Observable
import io.reactivex.functions.BiFunction import io.reactivex.functions.BiFunction
import io.reactivex.subjects.PublishSubject import io.reactivex.subjects.PublishSubject
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import timber.log.Timber
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
data class DevicesViewState( data class DevicesViewState(
@ -65,6 +65,7 @@ data class DeviceFullInfo(
val deviceInfo: DeviceInfo, val deviceInfo: DeviceInfo,
val cryptoDeviceInfo: CryptoDeviceInfo? val cryptoDeviceInfo: CryptoDeviceInfo?
) )
class DevicesViewModel @AssistedInject constructor( class DevicesViewModel @AssistedInject constructor(
@Assisted initialState: DevicesViewState, @Assisted initialState: DevicesViewState,
private val session: Session private val session: Session
@ -215,8 +216,13 @@ class DevicesViewModel @AssistedInject constructor(
private fun handleVerifyManually(action: DevicesAction.MarkAsManuallyVerified) = withState { state -> private fun handleVerifyManually(action: DevicesAction.MarkAsManuallyVerified) = withState { state ->
viewModelScope.launch { viewModelScope.launch {
if (state.hasAccountCrossSigning) { if (state.hasAccountCrossSigning) {
awaitCallback<Unit> { try {
tryThis { session.cryptoService().crossSigningService().trustDevice(action.cryptoDeviceInfo.deviceId, it) } awaitCallback<Unit> {
session.cryptoService().crossSigningService().trustDevice(action.cryptoDeviceInfo.deviceId, it)
}
} catch (failure: Throwable) {
Timber.e("Failed to manually cross sign device ${action.cryptoDeviceInfo.deviceId} : ${failure.localizedMessage}")
_viewEvents.post(DevicesViewEvents.Failure(failure))
} }
} else { } else {
// legacy // legacy