Cancel all on going to settings

This commit is contained in:
Valere 2020-03-24 17:48:16 +01:00
parent bddd70afdb
commit 2c9a8865bf
1 changed files with 6 additions and 5 deletions

View File

@ -155,6 +155,11 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
} }
fun confirmCancel() = withState { state -> fun confirmCancel() = withState { state ->
cancelAllPendingVerifications(state)
_viewEvents.post(VerificationBottomSheetViewEvents.Dismiss)
}
private fun cancelAllPendingVerifications(state: VerificationBottomSheetViewState) {
session.cryptoService() session.cryptoService()
.verificationService().getExistingVerificationRequest(state.otherUserMxItem?.id ?: "", state.transactionId)?.let { .verificationService().getExistingVerificationRequest(state.otherUserMxItem?.id ?: "", state.transactionId)?.let {
session.cryptoService().verificationService().cancelVerificationRequest(it) session.cryptoService().verificationService().cancelVerificationRequest(it)
@ -163,7 +168,6 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
.verificationService() .verificationService()
.getExistingTransaction(state.otherUserMxItem?.id ?: "", state.transactionId ?: "") .getExistingTransaction(state.otherUserMxItem?.id ?: "", state.transactionId ?: "")
?.cancel(CancelCode.User) ?.cancel(CancelCode.User)
_viewEvents.post(VerificationBottomSheetViewEvents.Dismiss)
} }
fun continueFromCancel() { fun continueFromCancel() {
@ -185,10 +189,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
} }
fun goToSettings() = withState { state -> fun goToSettings() = withState { state ->
session.cryptoService() cancelAllPendingVerifications(state)
.verificationService()
.getExistingTransaction(state.otherUserMxItem?.id ?: "", state.transactionId ?: "")
?.cancel(CancelCode.User)
_viewEvents.post(VerificationBottomSheetViewEvents.GoToSettings) _viewEvents.post(VerificationBottomSheetViewEvents.GoToSettings)
} }