Watch: what changed on Recent cards and the thread screen, search in All threads, a switching complication with Allow and Deny in the Smart Stack, and question options on notifications
This commit is contained in:
1 parent
f8241e42bb
commit
bfcbb69550
29 files changed
+1100
-137
No files matched your search
@@ -0,0 +1,37 @@
|
||||
// Allow and Deny on the Smart Stack widget. WidgetKit runs the intent without opening the app, then
|
||||
// reloads the widget's timeline. A request someone already answered (409) counts as done.
|
||||
//
|
||||
// The app target compiles this file too, because WaitingView builds the buttons.
|
||||
|
||||
import AppIntents
|
||||
|
||||
struct RespondIntent: AppIntent {
|
||||
static let title: LocalizedStringResource = "Answer an approval"
|
||||
static let isDiscoverable = false
|
||||
|
||||
@Parameter(title: "Host") var hostId: String
|
||||
@Parameter(title: "Thread") var threadId: String
|
||||
@Parameter(title: "Request") var requestId: String
|
||||
@Parameter(title: "Decision") var decision: String
|
||||
|
||||
init() {}
|
||||
|
||||
init(_ approval: WaitingEntry.Approval, decision: ApprovalDecision) {
|
||||
hostId = approval.hostId
|
||||
threadId = approval.threadId
|
||||
requestId = approval.requestId
|
||||
self.decision = decision.rawValue
|
||||
}
|
||||
|
||||
func perform() async throws -> some IntentResult {
|
||||
guard let api = SharedState.api else { return .result() }
|
||||
do {
|
||||
try await api.respond(
|
||||
hostId: hostId, threadId: threadId,
|
||||
request: .decision(requestId: requestId, decision: ApprovalDecision(rawValue: decision)))
|
||||
} catch let error as GatewayError where error.isStale {
|
||||
// Answered already, on the watch or elsewhere. The reload shows what is next.
|
||||
}
|
||||
return .result()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user