CancelTempPresetIntent.swift 801 B

12345678910111213141516171819202122232425262728
  1. import AppIntents
  2. import Foundation
  3. @available(iOS 16.0, *) struct CancelTempPresetIntent: AppIntent {
  4. // Title of the action in the Shortcuts app
  5. static var title: LocalizedStringResource = "Cancel a temporary Preset"
  6. // Description of the action in the Shortcuts app
  7. static var description = IntentDescription("Cancel temporary preset.")
  8. internal var intentRequest: TempPresetsIntentRequest
  9. init() {
  10. intentRequest = TempPresetsIntentRequest()
  11. }
  12. @MainActor func perform() async throws -> some ProvidesDialog {
  13. do {
  14. try intentRequest.cancelTempTarget()
  15. return .result(
  16. dialog: IntentDialog(stringLiteral: "Temporary Target canceled")
  17. )
  18. } catch {
  19. throw error
  20. }
  21. }
  22. }