mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-13 00:33:28 +01:00
[Widgets]: Enhanced to isolate operations from multiple views of same widget type
This commit is contained in:
@@ -11,32 +11,9 @@ import AppIntents
|
||||
@available(iOS 17, *)
|
||||
final class WidgetUpdateIntent: WidgetConfigurationIntent, @unchecked Sendable {
|
||||
|
||||
static var title: LocalizedStringResource { "Intent for WidgetAppIntentConfiguration receiver type" }
|
||||
static var title: LocalizedStringResource { "Widget ID update Intent" }
|
||||
static var isDiscoverable: Bool { false }
|
||||
|
||||
var uuid: String = UUID().uuidString
|
||||
private var widgetID: String?
|
||||
|
||||
@Parameter(title: "ID", description: "Change this to unique ID to keep changes isolated from other widgets", default: "1")
|
||||
var ID: String?
|
||||
|
||||
// this static hack is required, coz we are making these intents stateful
|
||||
private static var directionMap: [String: Direction] = [:]
|
||||
|
||||
init(){
|
||||
print()
|
||||
}
|
||||
|
||||
func getDirection( _ widgetID: String) -> Direction? {
|
||||
// remove it, since the event is processed. if needed it will be added again
|
||||
return Self.directionMap.removeValue(forKey: widgetID)
|
||||
}
|
||||
|
||||
init(_ direction: Direction?, _ widgetID: String){
|
||||
Self.directionMap[widgetID] = direction
|
||||
}
|
||||
|
||||
func perform() async throws -> some IntentResult {
|
||||
return .result()
|
||||
}
|
||||
@Parameter(title: "ID", description: "Provide a numeric ID to identify the widget", default: 1)
|
||||
var ID: Int?
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user