16 lines
586 B
Swift
16 lines
586 B
Swift
import Foundation
|
|
import Intents
|
|
import PromiseKit
|
|
|
|
class WidgetActionsIntentHandler: NSObject, WidgetActionsIntentHandling {
|
|
func provideActionsOptionsCollection(
|
|
for intent: WidgetActionsIntent,
|
|
with completion: @escaping (INObjectCollection<IntentAction>?, Error?) -> Void
|
|
) {
|
|
let actions = Current.realm(objectTypes: [Action.self]).objects(Action.self)
|
|
.sorted(byKeyPath: #keyPath(Action.Position))
|
|
let performActions = Array(actions.map { IntentAction(action: $0) })
|
|
completion(.init(items: performActions), nil)
|
|
}
|
|
}
|