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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user