CancelOverrideIntent.swift 819 B

1234567891011121314151617181920212223242526
  1. import AppIntents
  2. import Foundation
  3. struct CancelOverrideIntent: AppIntent {
  4. // Title of the action in the Shortcuts app
  5. static var title = LocalizedStringResource("Cancel override", table: "ShortcutsDetail")
  6. // Description of the action in the Shortcuts app
  7. static var description = IntentDescription(.init("Cancel an active override", table: "ShortcutsDetail"))
  8. internal var intentRequest: OverridePresetsIntentRequest
  9. init() {
  10. intentRequest = OverridePresetsIntentRequest()
  11. }
  12. @MainActor func perform() async throws -> some ProvidesDialog {
  13. do {
  14. await intentRequest.cancelOverride()
  15. return .result(
  16. dialog: IntentDialog(LocalizedStringResource("Override canceled", table: "ShortcutsDetail"))
  17. )
  18. }
  19. }
  20. }