Showing error messages when the import fails

This commit is contained in:
Alexander Heinrich
2021-03-15 09:59:50 +01:00
parent 9406f817f3
commit e7a6135d95
2 changed files with 20 additions and 2 deletions

View File

@@ -125,7 +125,7 @@ struct ManageAccessoriesView: View {
do {
_ = try self.accessoryController.export(accessories: self.accessories)
}catch {
//TODO: Show alert
self.alertType = .exportFailed
}
}
@@ -133,7 +133,13 @@ struct ManageAccessoriesView: View {
do {
try self.accessoryController.importAccessories()
}catch {
//TODO: Show alert
if let importError = error as? AccessoryController.ImportError,
importError == .cancelled {
//User cancelled the import. No error
return
}
self.alertType = .importFailed
}
}

View File

@@ -365,6 +365,16 @@ struct OpenHaystackMainView: View {
return Alert(title: Text("Downloading locations failed"),
message: Text("We could not download any locations from Apple. Please try again later"),
dismissButton: Alert.Button.okay())
case .exportFailed:
return Alert(
title: Text("Export failed"),
message: Text("Please check that no the folder is writable and that you have the most current version of the app"),
dismissButton: .okay())
case .importFailed:
return Alert(
title: Text("Import failed"),
message: Text("Could not import the selected file. Please make sure it has not been modified and that you have the current version of the app."),
dismissButton: .okay())
}
}
@@ -383,6 +393,8 @@ struct OpenHaystackMainView: View {
case activatePlugin
case pluginInstallFailed
case selectDepoyTarget
case exportFailed
case importFailed
}
}