From 30d4d80321d6b444c20f25bc975e6a697a945b3e Mon Sep 17 00:00:00 2001 From: Laurent Date: Thu, 16 Mar 2023 10:57:15 +0100 Subject: [PATCH] Fixes siri launch --- LeCountdown/Conductor.swift | 2 ++ LeCountdown/Intent/StartTimerIntent.swift | 12 ++++++------ LeCountdown/Intent/TimerShortcuts.swift | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/LeCountdown/Conductor.swift b/LeCountdown/Conductor.swift index c178306..ae4d1f5 100644 --- a/LeCountdown/Conductor.swift +++ b/LeCountdown/Conductor.swift @@ -25,6 +25,8 @@ class Conductor: ObservableObject { static let maestro: Conductor = Conductor() + var test: TestSound? = nil + @Published var soundPlayer: SoundPlayer? = nil fileprivate var _delayedSoundPlayers: [TimerID : DelaySoundPlayer] = [:] diff --git a/LeCountdown/Intent/StartTimerIntent.swift b/LeCountdown/Intent/StartTimerIntent.swift index 9d3426a..beb6319 100644 --- a/LeCountdown/Intent/StartTimerIntent.swift +++ b/LeCountdown/Intent/StartTimerIntent.swift @@ -10,7 +10,7 @@ import AppIntents import SwiftUI @available(iOS 16.0, macOS 13.0, watchOS 9.0, tvOS 16.0, *) -struct StartTimerIntent: AudioStartingIntent, CustomIntentMigratedAppIntent { +struct StartTimerIntent: AudioStartingIntent { static let intentClassName = "StartTimerIntent" static var title: LocalizedStringResource = "Launch Timer" @@ -25,7 +25,7 @@ struct StartTimerIntent: AudioStartingIntent, CustomIntentMigratedAppIntent { static var openAppWhenRun: Bool = true - func perform() async throws -> some IntentResult & ProvidesDialog & ShowsSnippetView { + func perform() async throws -> some IntentResult { let timerIdentifier: TimerIdentifierAppEntity if let timer { @@ -38,14 +38,14 @@ struct StartTimerIntent: AudioStartingIntent, CustomIntentMigratedAppIntent { do { let _ = try await TimerRouter.performAction(timer: abstractTimer) print("perform() success !") - return .result(dialog: "Timer \(abstractTimer.displayName) started") + return .result(value: 1) } catch { Logger.error(error) - let dialog: IntentDialog = "\(error.localizedDescription)" - return .result(dialog: dialog) +// let dialog: IntentDialog = "\(error.localizedDescription)" + return .result(value: 0) } } - return .result(dialog: "The timer has not been found in the app") + return .result(value: 0) } func timerEntities() -> [TimerIdentifierAppEntity] { diff --git a/LeCountdown/Intent/TimerShortcuts.swift b/LeCountdown/Intent/TimerShortcuts.swift index 3a7615d..dc1c39a 100644 --- a/LeCountdown/Intent/TimerShortcuts.swift +++ b/LeCountdown/Intent/TimerShortcuts.swift @@ -10,6 +10,7 @@ import AppIntents struct TimerShortcuts: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { + AppShortcut(intent: StartTimerIntent(), phrases: [ "\(.applicationName) \(\.$timer)", "Start \(\.$timer) with \(.applicationName)",