Alerts choose their own fuel, independent of the Stations tab

The proximity monitor was tied to the Stations-tab fuel selection, so
switching the list to another fuel silently re-targeted geofences. Now the
Alerts tab has its own 'Fuel to monitor' picker (persisted as
fuelboard.alertsFuel):
- Monitor reads loadAlertsFuel() on init/background relaunch
- Changing the alerts fuel re-registers geofences around stations selling
  that fuel only
- Favourites priority slots stay scoped to the monitored fuel
- Tests: alerts fuel round-trip + default (33/33 passing)
This commit is contained in:
FuelBoard Contributor
2026-08-12 08:51:31 +01:00
parent 35e0adaf0b
commit 46d5d45c93
5 changed files with 67 additions and 11 deletions
+16
View File
@@ -247,6 +247,7 @@ struct FuelStore {
static let favouritesKey = "fuelboard.favourites" // [FavouriteEntry] JSON
static let alertsEnabledKey = "fuelboard.alertsEnabled" // Bool
static let alertsRadiusKey = "fuelboard.alertsRadius" // Double km
static let alertsFuelKey = "fuelboard.alertsFuel" // FuelType raw value
static let onboardingCompletedKey = "fuelboard.onboardingCompleted" // Bool
static let lastRefreshKey = "fuelboard.lastRefresh" // TimeInterval (seconds since 1970)
@@ -312,6 +313,21 @@ struct FuelStore {
saveString(fuel.rawValue, service: fuelKey)
}
// MARK: Alerts fuel
/// The fuel proximity alerts monitor independent of the Stations-tab
/// selection so users can browse any fuel without re-targeting alerts.
static func loadAlertsFuel() -> FuelType {
if let raw = loadString(service: alertsFuelKey), let fuel = FuelType(rawValue: raw) {
return fuel
}
return .e10
}
static func saveAlertsFuel(_ fuel: FuelType) {
saveString(fuel.rawValue, service: alertsFuelKey)
}
// MARK: Sort mode
static func loadSortMode() -> SortMode {