mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 15:22:39 +00:00
Device Verification: Display the "The other party cancelled the verification." modal
This commit is contained in:
parent
d7d78b063b
commit
785bc7f176
8 changed files with 38 additions and 10 deletions
|
@ -796,6 +796,7 @@
|
|||
// MARK: - Device Verification
|
||||
"device_verification_title" = "Verify device";
|
||||
"device_verification_security_advice" = "For maximum security, we recommend you do this in person or use another trusted means of communication";
|
||||
"device_verification_cancelled" = "The other party cancelled the verification.";
|
||||
|
||||
// MARK: - Start
|
||||
"device_verification_start_title" = "Verify by comparing a short text string";
|
||||
|
|
|
@ -426,6 +426,10 @@ internal enum VectorL10n {
|
|||
internal static var decline: String {
|
||||
return VectorL10n.tr("Vector", "decline")
|
||||
}
|
||||
/// The other party cancelled the verification.
|
||||
internal static var deviceVerificationCancelled: String {
|
||||
return VectorL10n.tr("Vector", "device_verification_cancelled")
|
||||
}
|
||||
/// For maximum security, we recommend you do this in person or use another trusted means of communication
|
||||
internal static var deviceVerificationSecurityAdvice: String {
|
||||
return VectorL10n.tr("Vector", "device_verification_security_advice")
|
||||
|
|
|
@ -84,11 +84,11 @@ final class DeviceVerificationCoordinator: DeviceVerificationCoordinatorType {
|
|||
return // TODO
|
||||
}
|
||||
|
||||
//let rootCoordinator = sself.createDeviceVerificationStartCoordinator(otherUser: otherUser, otherDevice: otherDevice)
|
||||
let rootCoordinator = sself.createDeviceVerificationStartCoordinator(otherUser: otherUser, otherDevice: otherDevice)
|
||||
|
||||
// TODO: To remove. Only for dev
|
||||
let rootCoordinator = DeviceVerificationVerifyCoordinator(session: sself.session)
|
||||
rootCoordinator.delegate = self
|
||||
//let rootCoordinator = DeviceVerificationVerifyCoordinator(session: sself.session)
|
||||
//rootCoordinator.delegate = self
|
||||
|
||||
rootCoordinator.start()
|
||||
|
||||
|
|
|
@ -157,7 +157,9 @@ final class DeviceVerificationStartViewController: UIViewController {
|
|||
case .loading:
|
||||
self.renderLoading()
|
||||
case .loaded:
|
||||
self.renderLoaded()
|
||||
self.renderStarted()
|
||||
case .cancelled(let reason):
|
||||
self.renderCancelled(reason: reason)
|
||||
case .error(let error):
|
||||
self.render(error: error)
|
||||
}
|
||||
|
@ -167,13 +169,21 @@ final class DeviceVerificationStartViewController: UIViewController {
|
|||
self.activityPresenter.presentActivityIndicator(on: self.view, animated: true)
|
||||
}
|
||||
|
||||
private func renderLoaded() {
|
||||
private func renderStarted() {
|
||||
self.activityPresenter.removeCurrentActivityIndicator(animated: true)
|
||||
|
||||
self.verifyButtonBackgroundView.isHidden = true
|
||||
self.waitingPartnerLabel.isHidden = false
|
||||
self.useLegacyVerificationLabel.isHidden = false
|
||||
}
|
||||
|
||||
private func renderCancelled(reason: MXTransactionCancelCode) {
|
||||
self.activityPresenter.removeCurrentActivityIndicator(animated: true)
|
||||
|
||||
self.errorPresenter.presentError(from: self, title: "", message: VectorL10n.deviceVerificationCancelled, animated: true) {
|
||||
self.viewModel.process(viewAction: .cancel)
|
||||
}
|
||||
}
|
||||
|
||||
private func render(error: Error) {
|
||||
self.activityPresenter.removeCurrentActivityIndicator(animated: true)
|
||||
|
|
|
@ -114,7 +114,10 @@ final class DeviceVerificationStartViewModel: DeviceVerificationStartViewModelTy
|
|||
case MXSASTransactionStateShowSAS:
|
||||
self.coordinatorDelegate?.deviceVerificationStartViewModel(self, didCompleteWithOutgoingTransaction: transaction)
|
||||
case MXSASTransactionStateCancelled:
|
||||
self.coordinatorDelegate?.deviceVerificationStartViewModel(self, didTransactionCancelled: transaction)
|
||||
guard let reason = transaction.reasonCancelCode else {
|
||||
return
|
||||
}
|
||||
self.update(viewState: .cancelled(reason))
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import Foundation
|
|||
/// DeviceVerificationStartViewController view state
|
||||
enum DeviceVerificationStartViewState {
|
||||
case loading
|
||||
case loaded
|
||||
case loaded // started
|
||||
case cancelled(MXTransactionCancelCode)
|
||||
case error(Error)
|
||||
}
|
||||
|
|
|
@ -175,7 +175,11 @@ final class DeviceVerificationVerifyViewController: UIViewController {
|
|||
}
|
||||
|
||||
private func renderCancelled(reason: MXTransactionCancelCode) {
|
||||
// TODO
|
||||
self.activityPresenter.removeCurrentActivityIndicator(animated: true)
|
||||
|
||||
self.errorPresenter.presentError(from: self, title: "", message: VectorL10n.deviceVerificationCancelled, animated: true) {
|
||||
self.viewModel.process(viewAction: .cancel)
|
||||
}
|
||||
}
|
||||
|
||||
private func renderCancelledByMe(reason: MXTransactionCancelCode) {
|
||||
|
|
|
@ -66,21 +66,26 @@ final class DeviceVerificationVerifyViewModel: DeviceVerificationVerifyViewModel
|
|||
func process(viewAction: DeviceVerificationVerifyViewAction) {
|
||||
switch viewAction {
|
||||
case .confirm:
|
||||
self.confirm()
|
||||
self.confirmTransaction()
|
||||
case .complete:
|
||||
self.coordinatorDelegate?.deviceVerificationVerifyViewModelDidComplete(self)
|
||||
case .cancel:
|
||||
self.cancelTransaction()
|
||||
self.coordinatorDelegate?.deviceVerificationVerifyViewModelDidCancel(self)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func confirm() {
|
||||
private func confirmTransaction() {
|
||||
self.update(viewState: .loading)
|
||||
|
||||
self.transaction.confirmSASMatch()
|
||||
}
|
||||
|
||||
private func cancelTransaction() {
|
||||
self.transaction.cancel(with: MXTransactionCancelCode.user())
|
||||
}
|
||||
|
||||
private func update(viewState: DeviceVerificationVerifyViewState) {
|
||||
self.viewDelegate?.deviceVerificationVerifyViewModel(self, didUpdateViewState: viewState)
|
||||
|
|
Loading…
Reference in a new issue