Files
attendi/Widgets/Attendi/Sources/Intents/ProcessRecordingIntent.swift
T

37 lines
1.5 KiB
Swift

#if os(iOS)
import AppIntents
import Commanding
/// The intent behind the send button of the recording Live Activity, which sends the paused recording for processing.
///
/// The intent is compiled into both the app and the widget extension: the widget references it from the activity's buttons, and the
/// system executes it in the app's process — where it sends ``RecordingCommand/process`` through the process-wide
/// ``RecordingCommander``, mirroring a press of the feature's send button.
struct ProcessRecordingIntent: LiveActivityIntent {
// MARK: Constants
/// The localized title of the intent, resolved from the widget target's string catalog and shown wherever the system surfaces
/// the intent.
static let title: LocalizedStringResource = "intent.processing-recording.title"
/// The localized description of the intent, resolved from the widget target's string catalog.
static let description = IntentDescription("intent.processing-recording.description")
/// Whether running the intent brings the app to the foreground; `true`, so sending the recording for processing opens the app
/// from the Live Activity.
static let openAppWhenRun = true
// MARK: Methods
/// Sends the process command to the recording flow.
///
/// - Returns: An empty result, since the outcome surfaces through the Live Activity's own content update.
@MainActor
func perform() async throws -> some IntentResult {
RecordingCommander.shared.send(.process)
return .result()
}
}
#endif