mirror of
https://github.com/home-assistant/iOS.git
synced 2026-06-18 02:46:38 -05:00
## Summary This pr intruduces the following changes: - Upgrades the [Alomofire dependecy](142efae0cc). - Removes not needed [available anotations](a4e71a3c88) and split up code in multiple files; The anotations are not needed since https://github.com/home-assistant/iOS/pull/2469. ## Screenshots No user faceing changes ## Link to pull request in Documentation repository NA ## Any other notes NA
36 lines
1.0 KiB
Swift
36 lines
1.0 KiB
Swift
import Foundation
|
|
import Intents
|
|
import Shared
|
|
|
|
public class VoiceShortcutsManager {
|
|
public var voiceShortcuts: [INVoiceShortcut] = []
|
|
|
|
public init() {
|
|
updateVoiceShortcuts(completion: nil)
|
|
}
|
|
|
|
public func voiceShortcut(for identifier: String) -> INVoiceShortcut? {
|
|
voiceShortcuts.first { voiceShortcut -> Bool in
|
|
if let uuid = UUID(uuidString: identifier) {
|
|
return voiceShortcut.identifier == uuid
|
|
}
|
|
return false
|
|
}
|
|
}
|
|
|
|
public func updateVoiceShortcuts(completion: (() -> Void)?) {
|
|
INVoiceShortcutCenter.shared.getAllVoiceShortcuts { voiceShortcutsFromCenter, error in
|
|
guard let voiceShortcutsFromCenter else {
|
|
if let error {
|
|
Current.Log.error("Failed to fetch voice shortcuts with error: \(error)")
|
|
}
|
|
return
|
|
}
|
|
self.voiceShortcuts = voiceShortcutsFromCenter
|
|
if let completion {
|
|
completion()
|
|
}
|
|
}
|
|
}
|
|
}
|