Fixes siri launch

main
Laurent 3 years ago
parent 37141bb579
commit 30d4d80321
  1. 2
      LeCountdown/Conductor.swift
  2. 12
      LeCountdown/Intent/StartTimerIntent.swift
  3. 1
      LeCountdown/Intent/TimerShortcuts.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] = [:]

@ -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] {

@ -10,6 +10,7 @@ import AppIntents
struct TimerShortcuts: AppShortcutsProvider {
static var appShortcuts: [AppShortcut] {
AppShortcut(intent: StartTimerIntent(), phrases: [
"\(.applicationName) \(\.$timer)",
"Start \(\.$timer) with \(.applicationName)",

Loading…
Cancel
Save