Don't show dialog on cancel if self-verifying

The user should know they cancelled in if they're self verifying since
they're the one who cancelled, from their other device (the copy referred
to 'the other party', so was inaccurate, so we may as well just remove it).
This commit is contained in:
David Baker
2021-07-09 16:38:25 +01:00
parent af14fb31d1
commit d1e7173383
3 changed files with 16 additions and 7 deletions
@@ -159,8 +159,8 @@ final class KeyVerificationVerifyByScanningViewController: UIViewController {
self.render(error: error)
case .scannedCodeValidated(let isValid):
self.renderScannedCode(valid: isValid)
case .cancelled(let reason):
self.renderCancelled(reason: reason)
case .cancelled(let reason, let verificationKind):
self.renderCancelled(reason: reason, verificationKind: verificationKind)
case .cancelledByMe(let reason):
self.renderCancelledByMe(reason: reason)
}
@@ -236,12 +236,21 @@ final class KeyVerificationVerifyByScanningViewController: UIViewController {
}
}
private func renderCancelled(reason: MXTransactionCancelCode) {
private func renderCancelled(reason: MXTransactionCancelCode,
verificationKind: KeyVerificationKind) {
self.activityPresenter.removeCurrentActivityIndicator(animated: true)
self.stopQRCodeScanningIfPresented()
self.errorPresenter.presentError(from: self.alertPresentingViewController, title: "", message: VectorL10n.deviceVerificationCancelled, animated: true) {
// if we're verifying with someone else, let the user know threy cancelled.
// if we're verifying our own device, assume the user probably knows since it them who
// cancelled on their other device
if verificationKind == .user {
self.errorPresenter.presentError(from: self.alertPresentingViewController, title: "", message: VectorL10n.deviceVerificationCancelled, animated: true) {
self.dismissQRCodeScanningIfPresented(animated: false)
self.viewModel.process(viewAction: .cancel)
}
} else {
self.dismissQRCodeScanningIfPresented(animated: false)
self.viewModel.process(viewAction: .cancel)
}
@@ -225,7 +225,7 @@ final class KeyVerificationVerifyByScanningViewModel: KeyVerificationVerifyBySca
return
}
self.unregisterTransactionDidStateChangeNotification()
self.update(viewState: .cancelled(reason))
self.update(viewState: .cancelled(cancelCode: reason, verificationKind: verificationKind))
case MXSASTransactionStateCancelledByMe:
guard let reason = transaction.reasonCancelCode else {
return
@@ -251,7 +251,7 @@ final class KeyVerificationVerifyByScanningViewModel: KeyVerificationVerifyBySca
return
}
self.unregisterTransactionDidStateChangeNotification()
self.update(viewState: .cancelled(reason))
self.update(viewState: .cancelled(cancelCode: reason, verificationKind: verificationKind))
case .cancelledByMe:
guard let reason = transaction.reasonCancelCode else {
return
@@ -29,7 +29,7 @@ enum KeyVerificationVerifyByScanningViewState {
case loading
case loaded(viewData: KeyVerificationVerifyByScanningViewData)
case scannedCodeValidated(isValid: Bool)
case cancelled(MXTransactionCancelCode)
case cancelled(cancelCode: MXTransactionCancelCode, verificationKind: KeyVerificationKind)
case cancelledByMe(MXTransactionCancelCode)
case error(Error)
}