Cheapest reference uses chosen miles radius (same pool as list) in app + widget; header shows 'within N miles'

This commit is contained in:
FuelBoard Contributor
2026-08-11 18:29:20 +01:00
parent bcf4ea4f81
commit e0a5bb3d5d
3 changed files with 10 additions and 11 deletions
+3 -2
View File
@@ -85,10 +85,11 @@ struct FuelPriceTimelineProvider: TimelineProvider {
}
// 3) Load stations, then sort by price (distance tiebreak), scoped to
// the alert trigger radius so the widget's "cheapest" matches the app.
// the chosen search radius (miles) so the widget's "cheapest" matches
// the app's list.
var stations = FuelStore.loadStations()
if stations.isEmpty { stations = SampleFuelProvider.sampleStations }
let radiusKM = FuelStore.loadAlertsRadius()
let radiusKM = Double(FuelStore.loadStationLimit()) * 1.60934 // miles km
if let location {
let within = stations.filter {
$0.distanceKM(to: location.lat, lng2: location.lng) <= radiusKM