mirror of
https://github.com/passepartoutvpn/wireguard-apple.git
synced 2025-02-16 21:02:02 +00:00
Importing: Make use of lastError returned from TunnelsManager.addMultiple()
This commit is contained in:
parent
415e1e7c0c
commit
f49bfbee48
@ -56,29 +56,28 @@ class TunnelImporter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dispatchGroup.notify(queue: .main) {
|
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 {
|
if !configs.isEmpty && numberSuccessful == configs.count {
|
||||||
completionHandler?()
|
completionHandler?()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let title: String
|
let alertText: (title: String, message: String)?
|
||||||
let message: String
|
|
||||||
if urls.count == 1 {
|
if urls.count == 1 {
|
||||||
if urls.first!.pathExtension.lowercased() == "zip" && !configs.isEmpty {
|
if urls.first!.pathExtension.lowercased() == "zip" && !configs.isEmpty {
|
||||||
title = tr(format: "alertImportedFromZipTitle (%d)", numberSuccessful)
|
alertText = (title: tr(format: "alertImportedFromZipTitle (%d)", numberSuccessful),
|
||||||
message = tr(format: "alertImportedFromZipMessage (%1$d of %2$d)", numberSuccessful, configs.count)
|
message: tr(format: "alertImportedFromZipMessage (%1$d of %2$d)", numberSuccessful, configs.count))
|
||||||
} else if let lastFileImportErrorText = lastFileImportErrorText {
|
|
||||||
title = lastFileImportErrorText.title
|
|
||||||
message = lastFileImportErrorText.message
|
|
||||||
} else {
|
} else {
|
||||||
completionHandler?()
|
alertText = lastFileImportErrorText ?? lastAddError?.alertText
|
||||||
return
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
title = tr(format: "alertImportedFromMultipleFilesTitle (%d)", numberSuccessful)
|
alertText = (title: tr(format: "alertImportedFromMultipleFilesTitle (%d)", numberSuccessful),
|
||||||
message = tr(format: "alertImportedFromMultipleFilesMessage (%1$d of %2$d)", numberSuccessful, configs.count)
|
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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user