Live Activity: price now respects the Price display style — style carried in ContentState (captured at push time, extension renders deterministically instead of re-reading storage), setting change pushes an in-place content update via explicit override (no save-ordering race)

This commit is contained in:
FuelBoard Contributor
2026-08-14 21:06:04 +01:00
parent 8a589a35c1
commit bfb59d498a
4 changed files with 29 additions and 7 deletions
+11 -2
View File
@@ -322,13 +322,21 @@ struct ContentView: View {
fuel: alertsFuel, radiusKM: effectiveAlertsRadiusKM)
}
}
.onChange(of: priceDisplayStyle) { _, newValue in
// The pill carries its own display style in content state push
// an update so the running activity re-renders in the new style
// immediately. Pass the style explicitly: SettingsView saves it
// in its own onChange, whose ordering vs this one isn't guaranteed,
// so reading storage here could push the OLD style.
updateLiveActivity(priceDisplayStyleOverride: newValue)
}
}
/// Pushes the current best-in-radius station into the Live Activity.
/// No-op (or ends the activity) when the toggle is off or there's no
/// location/data yet. Uses the Live Activity's OWN fuel + radius (set in
/// Settings) independent of the Stations-tab fuel/distance.
private func updateLiveActivity() {
private func updateLiveActivity(priceDisplayStyleOverride: PriceDisplayStyle? = nil) {
// "Follow search" mirrors the Stations-tab distance exactly (no cap
// the pill only displays, it doesn't geofence).
let radiusKM = liveActivityFollowsSearch
@@ -339,7 +347,8 @@ struct ContentView: View {
fuel: liveActivityFuel,
radiusKM: radiusKM,
location: location,
enabled: liveActivityEnabled
enabled: liveActivityEnabled,
priceDisplayStyle: priceDisplayStyleOverride
)
}