Small widget favourites config: fuel dictates the favourite list (@IntentParameterDependency filters picker options by the chosen fuel), fuel picker shows only fuels with favourites (FavouriteFuel entity), Favourites sort hidden when no favourites exist (WidgetSort → dynamic AppEntity), fuel tags removed from favourite rows

This commit is contained in:
FuelBoard Contributor
2026-08-13 17:14:14 +01:00
parent d8506a035f
commit d0bd4e7a8e
2 changed files with 113 additions and 42 deletions
+5 -4
View File
@@ -165,14 +165,15 @@ struct FuelPriceTimelineProvider<Configuration: WidgetConfigurationIntent & Widg
// fuel, no radius. Freshen its price when a focused fetch covers
// it. The chosen favourite wins; when it's missing or stale (fresh
// widget, favourite removed, fuel row changed) fall back to the
// Fuel row's cheapest favourite so the face is never blank.
// favourites fuel's cheapest favourite so the face is never blank.
if let chosen = configuration.favouriteChoice {
let favouriteFuelType = configuration.favouriteFuelChoice?.fuel ?? fuel
let pinned = favourites.first { $0.id == chosen.id }
?? favourites
.filter { $0.fuel == fuel && $0.station.prices[fuel] != nil }
.filter { $0.fuel == favouriteFuelType && $0.station.prices[favouriteFuelType] != nil }
.min { lhs, rhs in
(lhs.station.prices[fuel] ?? .infinity) <
(rhs.station.prices[fuel] ?? .infinity)
(lhs.station.prices[favouriteFuelType] ?? .infinity) <
(rhs.station.prices[favouriteFuelType] ?? .infinity)
}
if let pinned {
var station = pinned.station