iOS 1.0 RC 1: battery and heat work, version label, web player redraw tweaks
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0fc35b13e8
commit
c0e33b5e3e
18 files changed
+143
-36
No files matched your search
@@ -34,6 +34,7 @@ final class WidgetBridge: @unchecked Sendable {
|
||||
private var last: WidgetSnapshot?
|
||||
private var artKey: String?
|
||||
private var savedArt: String?
|
||||
private var pending: DispatchWorkItem?
|
||||
|
||||
func start(_ g: AppGraph) {
|
||||
let pm = g.playback, s = g.settings, plex = g.plex
|
||||
@@ -46,13 +47,19 @@ final class WidgetBridge: @unchecked Sendable {
|
||||
}
|
||||
|
||||
/// Writes the snapshot and asks WidgetKit to redraw, but only when something the widgets show has changed.
|
||||
/// Changes settle for a moment first: a fader drag would otherwise relaunch the widget extension every frame.
|
||||
func publish(_ pm: PlaybackManager, _ s: Settings, force: Bool = false) {
|
||||
let snap = make(pm, s)
|
||||
guard force || snap != last else { return }
|
||||
last = snap
|
||||
WidgetStore.save(snap)
|
||||
WidgetCenter.shared.reloadAllTimelines()
|
||||
if #available(iOS 18.0, *) { ControlCenter.shared.reloadAllControls() }
|
||||
pending?.cancel()
|
||||
let push = DispatchWorkItem {
|
||||
WidgetStore.save(snap)
|
||||
WidgetCenter.shared.reloadAllTimelines()
|
||||
if #available(iOS 18.0, *) { ControlCenter.shared.reloadAllControls() }
|
||||
}
|
||||
pending = push
|
||||
if force { push.perform() } else { DispatchQueue.main.asyncAfter(deadline: .now() + 0.6, execute: push) }
|
||||
}
|
||||
|
||||
private func make(_ pm: PlaybackManager, _ s: Settings) -> WidgetSnapshot {
|
||||
|
||||
Reference in new issue
Block a user