Skip to content

Commit

Permalink
Showing error messages when the import fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Sn0wfreezeDev committed Mar 15, 2021
1 parent 9406f81 commit e7a6135
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,21 @@ struct ManageAccessoriesView: View {
do {
_ = try self.accessoryController.export(accessories: self.accessories)
}catch {
//TODO: Show alert
self.alertType = .exportFailed
}
}

func importAccessories() {
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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}

Expand All @@ -383,6 +393,8 @@ struct OpenHaystackMainView: View {
case activatePlugin
case pluginInstallFailed
case selectDepoyTarget
case exportFailed
case importFailed
}

}
Expand Down

0 comments on commit e7a6135

Please sign in to comment.