Files
hapi/ios/Hapi/Features/Widgets/WidgetSnapshotControlling.swift
T
17332c0053 feat(ios): show unread markers in session widgets
- Carry the last-seen watermark into the App Group widget snapshot as
  isUnread; the app refreshes the widget when read state changes.
- Mark push-updated sessions unread in the NSE snapshot path.
- Show a blue dot and blue timestamp for unread widget rows.

via [HAPI](https://hapi.run)

Co-Authored-By: HAPI <noreply@hapi.run>
Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-07 07:13:16 +08:00

34 lines
1.1 KiB
Swift

import HapiClient
import HapiProtocol
/// Cross-platform seam for the home-screen widget snapshot writer. The real
/// writer is iOS-only (WidgetKit); Catalyst gets a no-op.
@MainActor
protocol WidgetSnapshotControlling: AnyObject {
func update(_ sessions: [SessionSummary], unreadSessionIds: Set<String>, hubUrl: String)
func flush()
/// Background tasks must wait for the App Group write before they report
/// completion; iOS may suspend the process immediately afterwards.
func flushAndWait() async
func clear()
}
@MainActor
final class NoopWidgetSnapshotController: WidgetSnapshotControlling {
func update(_ sessions: [SessionSummary], unreadSessionIds: Set<String>, hubUrl: String) {}
func flush() {}
func flushAndWait() async {}
func clear() {}
}
enum WidgetSnapshotControllerFactory {
@MainActor
static func make() -> any WidgetSnapshotControlling {
#if os(iOS) && !targetEnvironment(macCatalyst)
return WidgetSnapshotUpdater()
#else
return NoopWidgetSnapshotController()
#endif
}
}