mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-22 01:22:46 +02:00
MESSENGER-5271 crosssigning - add alert and better strings, only show button when usable
This commit is contained in:
+2
-1
@@ -49,8 +49,9 @@ final class KeyVerificationSelfVerifyWaitCoordinator: KeyVerificationSelfVerifyW
|
||||
|
||||
// MARK: - Public methods
|
||||
|
||||
func start() {
|
||||
func start() {
|
||||
self.keyVerificationSelfVerifyWaitViewModel.coordinatorDelegate = self
|
||||
self.keyVerificationSelfVerifyWaitViewModel.checkCrosssigningDevices()
|
||||
}
|
||||
|
||||
func toPresentable() -> UIViewController {
|
||||
|
||||
+40
-1
@@ -55,6 +55,8 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {
|
||||
|
||||
private weak var cancelBarButtonItem: UIBarButtonItem?
|
||||
|
||||
private var verificationAlert: UIAlertController?
|
||||
|
||||
// MARK: - Setup
|
||||
|
||||
class func instantiate(with viewModel: KeyVerificationSelfVerifyWaitViewModelType, cancellable: Bool) -> KeyVerificationSelfVerifyWaitViewController {
|
||||
@@ -77,12 +79,13 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {
|
||||
|
||||
self.registerThemeServiceDidChangeThemeNotification()
|
||||
self.update(theme: self.theme)
|
||||
|
||||
self.viewModel.viewDelegate = self
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
|
||||
self.viewModel.viewDelegate = self
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +93,8 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {
|
||||
return self.theme.statusBarStyle
|
||||
}
|
||||
|
||||
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func update(theme: Theme) {
|
||||
@@ -146,6 +151,8 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {
|
||||
self.crosssigningButton.setTitle(BWIL10n.deviceVerificationCrosssigningWaitRecoverSecrets, for: .normal)
|
||||
|
||||
self.recoverSecretsAvailabilityLoadingContainerView.isHidden = true
|
||||
|
||||
self.crosssigningButton.isHidden = true
|
||||
}
|
||||
|
||||
private func render(viewState: KeyVerificationSelfVerifyWaitViewState) {
|
||||
@@ -162,6 +169,10 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {
|
||||
self.renderCancelledByMe(reason: reason)
|
||||
case .error(let error):
|
||||
self.render(error: error)
|
||||
case .verificationAccepted:
|
||||
self.verificationAccepted()
|
||||
case .crosssigningPossible(let possible):
|
||||
self.showCrosssigningButton(possible)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,6 +215,8 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {
|
||||
self.recoverSecretsAvailabilityActivityIndicatorView.stopAnimating()
|
||||
self.recoverSecretsContainerView.isHidden = hideRecoverSecrets
|
||||
self.recoverSecretsButton.setTitle(recoverSecretsButtonTitle, for: .normal)
|
||||
|
||||
self.showCrosssigningAlert()
|
||||
}
|
||||
|
||||
private func renderCancelled(reason: MXTransactionCancelCode) {
|
||||
@@ -234,6 +247,32 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {
|
||||
}
|
||||
}
|
||||
|
||||
private func verificationAccepted() {
|
||||
if let alert = self.verificationAlert {
|
||||
alert.dismiss(animated: false)
|
||||
}
|
||||
}
|
||||
|
||||
private func showCrosssigningButton(_ show: Bool) {
|
||||
self.crosssigningButton.isHidden = !show
|
||||
}
|
||||
|
||||
o // bwi: show an alert when corsssigning button is pressed. This makes it clearer to the user what to do next
|
||||
private func showCrosssigningAlert() {
|
||||
self.verificationAlert = UIAlertController(title: BWIL10n.secretsRecoveryVerificationAlertTitle,
|
||||
message: BWIL10n.secretsRecoveryVerificationAlertMessage,
|
||||
preferredStyle: .alert)
|
||||
|
||||
if let alert = self.verificationAlert {
|
||||
let cancelActionTitle = BWIL10n.secretsRecoveryVerificationAlertCancel
|
||||
let cancelAction = UIAlertAction(title: cancelActionTitle, style: .cancel)
|
||||
|
||||
alert.addAction(cancelAction)
|
||||
|
||||
present(alert, animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Actions
|
||||
|
||||
private func cancelButtonAction() {
|
||||
|
||||
+14
@@ -83,6 +83,18 @@ final class KeyVerificationSelfVerifyWaitViewModel: KeyVerificationSelfVerifyWai
|
||||
}
|
||||
}
|
||||
|
||||
// bwi: only show corsssigning button when there is more than one device in your account
|
||||
func checkCrosssigningDevices() {
|
||||
self.session.matrixRestClient.devices { [weak self] response in
|
||||
switch response {
|
||||
case .success(let devices):
|
||||
self?.update(viewState: .crosssigningPossible(devices.count > 1))
|
||||
case .failure:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func loadData() {
|
||||
@@ -258,6 +270,8 @@ final class KeyVerificationSelfVerifyWaitViewModel: KeyVerificationSelfVerifyWai
|
||||
}
|
||||
|
||||
if keyVerificationRequest.state == MXKeyVerificationRequestStateReady {
|
||||
self.update(viewState: .verificationAccepted)
|
||||
|
||||
self.unregisterKeyVerificationRequestChangeNotification()
|
||||
self.coordinatorDelegate?.keyVerificationSelfVerifyWaitViewModel(self,
|
||||
didAcceptKeyVerificationRequest: keyVerificationRequest)
|
||||
|
||||
+2
@@ -36,4 +36,6 @@ protocol KeyVerificationSelfVerifyWaitViewModelType {
|
||||
var coordinatorDelegate: KeyVerificationSelfVerifyWaitViewModelCoordinatorDelegate? { get set }
|
||||
|
||||
func process(viewAction: KeyVerificationSelfVerifyWaitViewAction)
|
||||
|
||||
func checkCrosssigningDevices()
|
||||
}
|
||||
|
||||
+2
@@ -36,4 +36,6 @@ enum KeyVerificationSelfVerifyWaitViewState {
|
||||
case cancelled(MXTransactionCancelCode)
|
||||
case cancelledByMe(MXTransactionCancelCode)
|
||||
case error(Error)
|
||||
case verificationAccepted
|
||||
case crosssigningPossible(Bool)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user