Results filter is now search radius in miles (5/10/15); relay fetch scoped to radius, limit 500; changing miles re-fetches; caption shows stations within N miles
This commit is contained in:
+10
-6
@@ -140,7 +140,7 @@ struct FuelStore {
|
||||
static let locationKey = "fuelboard.lastLocation" // "lat,lng,timestamp"
|
||||
static let fuelKey = "fuelboard.selectedFuel" // FuelType raw value
|
||||
static let sortModeKey = "fuelboard.sortMode" // SortMode raw value
|
||||
static let stationLimitKey = "fuelboard.stationLimit" // Int (10/25/50/75/100)
|
||||
static let stationLimitKey = "fuelboard.stationLimitMiles" // Int miles (5/10/15)
|
||||
static let favouritesKey = "fuelboard.favourites" // [FuelStation] JSON
|
||||
static let alertsEnabledKey = "fuelboard.alertsEnabled" // Bool
|
||||
static let alertsRadiusKey = "fuelboard.alertsRadius" // Double km
|
||||
@@ -209,17 +209,21 @@ struct FuelStore {
|
||||
saveString(mode.rawValue, service: sortModeKey)
|
||||
}
|
||||
|
||||
// MARK: Station count limit
|
||||
// MARK: Station search radius (miles)
|
||||
|
||||
/// Search radius options — the results filter shows stations within this
|
||||
/// many miles of the current location.
|
||||
static let stationRadiusOptions = [5, 10, 15]
|
||||
|
||||
static func loadStationLimit() -> Int {
|
||||
if let raw = loadString(service: stationLimitKey), let value = Int(raw), [10, 25, 50, 75, 100].contains(value) {
|
||||
if let raw = loadString(service: stationLimitKey), let value = Int(raw), stationRadiusOptions.contains(value) {
|
||||
return value
|
||||
}
|
||||
return 25
|
||||
return 5
|
||||
}
|
||||
|
||||
static func saveStationLimit(_ limit: Int) {
|
||||
saveString(String(limit), service: stationLimitKey)
|
||||
static func saveStationLimit(_ miles: Int) {
|
||||
saveString(String(miles), service: stationLimitKey)
|
||||
}
|
||||
|
||||
// MARK: Favourites
|
||||
|
||||
Reference in New Issue
Block a user