diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt b/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt index ac6155e02c..731f12cca4 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt @@ -155,6 +155,11 @@ class VerificationBottomSheetViewModel @AssistedInject constructor( } fun confirmCancel() = withState { state -> + cancelAllPendingVerifications(state) + _viewEvents.post(VerificationBottomSheetViewEvents.Dismiss) + } + + private fun cancelAllPendingVerifications(state: VerificationBottomSheetViewState) { session.cryptoService() .verificationService().getExistingVerificationRequest(state.otherUserMxItem?.id ?: "", state.transactionId)?.let { session.cryptoService().verificationService().cancelVerificationRequest(it) @@ -163,7 +168,6 @@ class VerificationBottomSheetViewModel @AssistedInject constructor( .verificationService() .getExistingTransaction(state.otherUserMxItem?.id ?: "", state.transactionId ?: "") ?.cancel(CancelCode.User) - _viewEvents.post(VerificationBottomSheetViewEvents.Dismiss) } fun continueFromCancel() { @@ -185,10 +189,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor( } fun goToSettings() = withState { state -> - session.cryptoService() - .verificationService() - .getExistingTransaction(state.otherUserMxItem?.id ?: "", state.transactionId ?: "") - ?.cancel(CancelCode.User) + cancelAllPendingVerifications(state) _viewEvents.post(VerificationBottomSheetViewEvents.GoToSettings) }