VoiceWake: autoplay chime on selection

This commit is contained in:
Peter Steinberger
2025-12-09 03:39:50 +01:00
parent dbcb97949f
commit 514b90ac69

View File

@@ -234,11 +234,11 @@ struct VoiceWakeSettings: View {
.frame(width: self.fieldLabelWidth, alignment: .leading)
Menu {
Button("No Sound") { selection.wrappedValue = .none }
Button("No Sound") { self.selectChime(.none, binding: selection) }
Divider()
ForEach(VoiceWakeChimeCatalog.systemOptions, id: \.self) { option in
Button(VoiceWakeChimeCatalog.displayName(for: option)) {
selection.wrappedValue = .system(name: option)
self.selectChime(.system(name: option), binding: selection)
}
}
Divider()
@@ -282,13 +282,20 @@ struct VoiceWakeSettings: View {
options: [.withSecurityScope],
includingResourceValuesForKeys: nil,
relativeTo: nil)
selection.wrappedValue = .custom(displayName: url.lastPathComponent, bookmark: bookmark)
let chosen = VoiceWakeChime.custom(displayName: url.lastPathComponent, bookmark: bookmark)
selection.wrappedValue = chosen
VoiceWakeChimePlayer.play(chosen)
} catch {
// Ignore failures; user can retry.
}
}
}
private func selectChime(_ chime: VoiceWakeChime, binding: Binding<VoiceWakeChime>) {
binding.wrappedValue = chime
VoiceWakeChimePlayer.play(chime)
}
private func sanitizedTriggers() -> [String] {
sanitizeVoiceWakeTriggers(self.state.swabbleTriggerWords)
}