aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-03-05 15:50:50 +0530
committerRoopesh Chander <roop@roopc.net>2019-03-05 16:11:41 +0530
commit90c0f7e92e193c391a171f10b080dbecae0beace (patch)
tree026c5eb78c8a9e966464e4e269462c5f8de5c0f4 /WireGuard
parentTunnelsManager: addMultiple() should also return the last error (diff)
downloadwireguard-apple-90c0f7e92e193c391a171f10b080dbecae0beace.tar.xz
wireguard-apple-90c0f7e92e193c391a171f10b080dbecae0beace.zip
Importing: Make use of lastError returned from TunnelsManager.addMultiple()
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to '')
-rw-r--r--WireGuard/WireGuard/UI/TunnelImporter.swift25
1 files changed, 12 insertions, 13 deletions
diff --git a/WireGuard/WireGuard/UI/TunnelImporter.swift b/WireGuard/WireGuard/UI/TunnelImporter.swift
index a306a7e0..1b0fd7e5 100644
--- a/WireGuard/WireGuard/UI/TunnelImporter.swift
+++ b/WireGuard/WireGuard/UI/TunnelImporter.swift
@@ -56,29 +56,28 @@ class TunnelImporter {
}
}
dispatchGroup.notify(queue: .main) {
- tunnelsManager.addMultiple(tunnelConfigurations: configs.compactMap { $0 }) { numberSuccessful, _ in
+ tunnelsManager.addMultiple(tunnelConfigurations: configs.compactMap { $0 }) { numberSuccessful, lastAddError in
if !configs.isEmpty && numberSuccessful == configs.count {
completionHandler?()
return
}
- let title: String
- let message: String
+ let alertText: (title: String, message: String)?
if urls.count == 1 {
if urls.first!.pathExtension.lowercased() == "zip" && !configs.isEmpty {
- title = tr(format: "alertImportedFromZipTitle (%d)", numberSuccessful)
- message = tr(format: "alertImportedFromZipMessage (%1$d of %2$d)", numberSuccessful, configs.count)
- } else if let lastFileImportErrorText = lastFileImportErrorText {
- title = lastFileImportErrorText.title
- message = lastFileImportErrorText.message
+ alertText = (title: tr(format: "alertImportedFromZipTitle (%d)", numberSuccessful),
+ message: tr(format: "alertImportedFromZipMessage (%1$d of %2$d)", numberSuccessful, configs.count))
} else {
- completionHandler?()
- return
+ alertText = lastFileImportErrorText ?? lastAddError?.alertText
}
} else {
- title = tr(format: "alertImportedFromMultipleFilesTitle (%d)", numberSuccessful)
- message = tr(format: "alertImportedFromMultipleFilesMessage (%1$d of %2$d)", numberSuccessful, configs.count)
+ alertText = (title: tr(format: "alertImportedFromMultipleFilesTitle (%d)", numberSuccessful),
+ message: tr(format: "alertImportedFromMultipleFilesMessage (%1$d of %2$d)", numberSuccessful, configs.count))
+ }
+ if let alertText = alertText {
+ errorPresenterType.showErrorAlert(title: alertText.title, message: alertText.message, from: sourceVC, onPresented: completionHandler)
+ } else {
+ completionHandler?()
}
- errorPresenterType.showErrorAlert(title: title, message: message, from: sourceVC, onPresented: completionHandler)
}
}
}