Overwrite pending profile when reimporting

- Overwrite title field
- Remove old .ovpn

useSuggestedTitle() is only called on load, it will never
overwrite user input unless there's a new import.
This commit is contained in:
Davide De Rosa 2018-10-27 20:38:08 +02:00
parent c084c71db3
commit 06ecd3367f
2 changed files with 4 additions and 6 deletions

View File

@ -115,6 +115,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
// already presented: update parsed configuration // already presented: update parsed configuration
if let nav = target as? UINavigationController, let wizard = nav.topViewController as? WizardHostViewController { if let nav = target as? UINavigationController, let wizard = nav.topViewController as? WizardHostViewController {
if let oldURL = wizard.parsedFile?.url {
try? FileManager.default.removeItem(at: oldURL)
}
wizard.parsedFile = parsedFile wizard.parsedFile = parsedFile
wizard.removesConfigurationOnCancel = true wizard.removesConfigurationOnCancel = true
return return

View File

@ -87,12 +87,7 @@ class WizardHostViewController: UITableViewController, TableModelHost {
// MARK: Actions // MARK: Actions
private func useSuggestedTitle() { private func useSuggestedTitle() {
guard let field = cellTitle?.field else { cellTitle?.field.text = parsedFile?.url.normalizedFilename
return
}
if field.text?.isEmpty ?? true {
field.text = parsedFile?.url.normalizedFilename
}
} }
@IBAction private func next() { @IBAction private func next() {