Fetch full-UK dump (no radius/limit); stations in app-group defaults only; alert path keeps focused radius fetch
This commit is contained in:
@@ -147,15 +147,19 @@ struct FuelStore {
|
||||
static let lastRefreshKey = "fuelboard.lastRefresh" // TimeInterval (seconds since 1970)
|
||||
|
||||
// MARK: Stations
|
||||
// The full-UK dataset (~2.9 MB) lives in app-group UserDefaults only —
|
||||
// keychain is for small values and cannot hold it. Read order is
|
||||
// defaults-first for stations (keychain may hold a legacy small set from
|
||||
// older builds; the full country dump always wins).
|
||||
|
||||
static func loadStations() -> [FuelStation] {
|
||||
if let data = keychainData(service: stationsKey),
|
||||
if let defaults = UserDefaults(suiteName: appGroupSuite),
|
||||
let data = defaults.data(forKey: stationsKey),
|
||||
let stations = try? JSONDecoder().decode([FuelStation].self, from: data),
|
||||
!stations.isEmpty {
|
||||
return stations
|
||||
}
|
||||
if let defaults = UserDefaults(suiteName: appGroupSuite),
|
||||
let data = defaults.data(forKey: stationsKey),
|
||||
if let data = keychainData(service: stationsKey),
|
||||
let stations = try? JSONDecoder().decode([FuelStation].self, from: data),
|
||||
!stations.isEmpty {
|
||||
return stations
|
||||
@@ -166,7 +170,7 @@ struct FuelStore {
|
||||
static func saveStations(_ stations: [FuelStation]) {
|
||||
if let data = try? JSONEncoder().encode(stations) {
|
||||
UserDefaults(suiteName: appGroupSuite)?.set(data, forKey: stationsKey)
|
||||
writeKeychain(data: data, service: stationsKey)
|
||||
// Intentionally NOT written to keychain — 2.9 MB exceeds its limits.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user