From 2c9a8865bfd985521c0cec7add74f89d73188b51 Mon Sep 17 00:00:00 2001 From: Valere Date: Tue, 24 Mar 2020 17:48:16 +0100 Subject: [PATCH] Cancel all on going to settings --- .../verification/VerificationBottomSheetViewModel.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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) }