From 8646521176ae8d30e20f2f4649825f576e0a7156 Mon Sep 17 00:00:00 2001 From: FuelBoard Contributor Date: Thu, 13 Aug 2026 18:51:41 +0100 Subject: [PATCH] =?UTF-8?q?Small=20widget:=20fuel-only=20relay=20fetch=20w?= =?UTF-8?q?hen=20no=20location,=20so=20default/Cheapest/Closest=20faces=20?= =?UTF-8?q?populate=20with=20real=20stations=20instead=20of=20sample=20dat?= =?UTF-8?q?a.=20Root=20cause=20of=20the=20persistent=20skeleton:=20favouri?= =?UTF-8?q?tes=20mode=20reads=20keychain=20(works=20on=20free=20accounts),?= =?UTF-8?q?=20but=20the=20non-favourites=20path=20needs=20stations=20?= =?UTF-8?q?=E2=80=94=20the=20app-group=20cache=20can=20be=20absent=20on=20?= =?UTF-8?q?free=20accounts=20and=20keychain=20can't=20hold=20the=20station?= =?UTF-8?q?=20dump,=20so=20with=20no=20location=20fix=20the=20widget=20fel?= =?UTF-8?q?l=20through=20to=20SampleFuelProvider=20and=20never=20populated?= =?UTF-8?q?.=20Now=20when=20location=20is=20nil=20the=20widget=20fetches?= =?UTF-8?q?=20/api/v1/stations=3Ffuel=3DX&limit=3D500=20(fuel-only,=20chea?= =?UTF-8?q?pest-first,=20verified=20against=20the=20relay).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FuelBoardWidgets/FuelPriceWidget.swift | 34 ++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/FuelBoardWidgets/FuelPriceWidget.swift b/FuelBoardWidgets/FuelPriceWidget.swift index 90eeb45..e358979 100644 --- a/FuelBoardWidgets/FuelPriceWidget.swift +++ b/FuelBoardWidgets/FuelPriceWidget.swift @@ -226,6 +226,16 @@ struct FuelPriceTimelineProvider [FuelStation]? { + var components = URLComponents( + url: RelayFuelProvider().baseURL.appendingPathComponent("api/v1/stations"), + resolvingAgainstBaseURL: false + )! + components.queryItems = [ + URLQueryItem(name: "fuel", value: fuel.rawValue), + URLQueryItem(name: "limit", value: String(limit)), + ] + var request = URLRequest(url: components.url!) + request.timeoutInterval = 5 + do { + let (data, response) = try await URLSession.shared.data(for: request) + guard let http = response as? HTTPURLResponse, http.statusCode == 200 else { return nil } + return try? FuelPriceProvider.decodeStations(from: data) + } catch { + return nil + } + } } struct FuelPriceWidgetView: View {