← All repositories

reportage

A life-logging app for iPhone

git clone https://code.inqk.net/reportage.git


Reportage/Services/InstantReportLogger.swift (1737B)

1import AppIntents
2
3/// Logs instant reports for `LogPassiveReportIntent`, which may run with the
4/// app launched in the background, as a notification's Instant Report does.
5struct InstantReportLogger: InstantReportLogging {
6    let persistence: PersistenceController
7
8    private static let log = EventLog.shared.category("Intents")
9
10    func logInstantReport() async throws {
11        let store = ReportStore(persistence: persistence)
12        Self.log.info("Filing an instant report from an intent")
13        try await PassiveLog(store: store, capture: { await ContextCapture.background.capture() })
14            .log(trigger: .intent)
15        await PromptScheduler().refresh()
16    }
17}
18
19/// Phrases for Siri and the Shortcuts app.
20struct ReportageShortcuts: AppShortcutsProvider {
21    static var appShortcuts: [AppShortcut] {
22        AppShortcut(
23            intent: LogPassiveReportIntent(),
24            phrases: [
25                "File a report in \(.applicationName)",
26                "Make a report in \(.applicationName)",
27                "Log a report in \(.applicationName)",
28                "Record a report in \(.applicationName)",
29                "File an update in \(.applicationName)",
30                "Make an update in \(.applicationName)",
31                "Log an update in \(.applicationName)",
32                "Record an update in \(.applicationName)",
33                "File an instant report in \(.applicationName)",
34                "Make an instant report in \(.applicationName)",
35                "Log an instant report in \(.applicationName)",
36                "Record an instant report in \(.applicationName)",
37            ],
38            shortTitle: "Instant Report",
39            systemImageName: "bolt.fill")
40    }
41}