Check for readiness before doing any import actions

This commit is contained in:
Danny Moesch 2020-02-10 21:59:56 +01:00 committed by Mingshen Sun
parent a5570a8409
commit ea27c73b99
2 changed files with 4 additions and 4 deletions

View file

@ -38,6 +38,9 @@ extension PGPKeyImporter {
extension PGPKeyImporter where Self: UIViewController {
func savePassphraseDialog() {
guard self.isReadyToUse() else {
return
}
let savePassphraseAlert = UIAlertController(title: "Passphrase".localize(), message: "WantToSavePassphrase?".localize(), preferredStyle: .alert)
// Do not save the key's passphrase.
savePassphraseAlert.addAction(UIAlertAction(title: "No".localize(), style: .default) { _ in

View file

@ -26,16 +26,13 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
}
@IBAction func savePGPKey(segue: UIStoryboardSegue) {
guard let sourceController = segue.source as? PGPKeyImporter else {
guard let sourceController = segue.source as? PGPKeyImporter, sourceController.isReadyToUse() else {
return
}
savePGPKey(using: sourceController)
}
private func savePGPKey(using keyImporter: PGPKeyImporter) {
guard keyImporter.isReadyToUse() else {
return
}
SVProgressHUD.setDefaultMaskType(.black)
SVProgressHUD.setDefaultStyle(.light)
SVProgressHUD.show(withStatus: "FetchingPgpKey".localize())