Small widget: remove @IntentParameterDependency from WidgetFavouriteQuery
Final structural difference from the working medium widget. The dependent-picker machinery resolves the favourite parameter through the hidden favouriteFuel parameter during fresh-widget default-config resolution (default Sort = Cheapest hides favouriteFuel), and that resolution fails on-device — the whole default config fails and the small widget strands on the skeleton. Favourite picker now lists ALL favourites, each row labelled with its fuel (the fuel-scoped filter was the dependency's only purpose). Configured Favourites-mode widgets are unaffected. Per-intent beacons remain in place to verify the outcome.
This commit is contained in:
@@ -76,8 +76,8 @@ struct WidgetDistanceQuery: EntityQuery {
|
|||||||
|
|
||||||
// Fuel for the favourites face (small widget, Favourites sort). Modelled as an
|
// Fuel for the favourites face (small widget, Favourites sort). Modelled as an
|
||||||
// AppEntity so only fuels that ACTUALLY have favourites appear in the picker —
|
// AppEntity so only fuels that ACTUALLY have favourites appear in the picker —
|
||||||
// mirrors the app's Favourites tab capsules. The chosen fuel dictates which
|
// mirrors the app's Favourites tab capsules. (The Favourite picker itself is
|
||||||
// favourites the Favourite picker offers (see WidgetFavouriteQuery).
|
// fuel-independent now — see WidgetFavouriteQuery.)
|
||||||
struct FavouriteFuel: AppEntity, Identifiable, Hashable, Codable {
|
struct FavouriteFuel: AppEntity, Identifiable, Hashable, Codable {
|
||||||
let fuel: FuelType
|
let fuel: FuelType
|
||||||
|
|
||||||
@@ -149,13 +149,15 @@ struct WidgetFavourite: AppEntity, Identifiable, Hashable, Codable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct WidgetFavouriteQuery: EntityQuery {
|
struct WidgetFavouriteQuery: EntityQuery {
|
||||||
/// Reads the small intent's Favourite Fuel parameter: the Favourite picker
|
// NO @IntentParameterDependency: the dependent-picker machinery resolves
|
||||||
/// only offers THAT fuel's favourites (requirement: the chosen fuel
|
// the favourite parameter through the (hidden, in Cheapest mode)
|
||||||
/// dictates the list). Nil (medium widget / fresh sheet) → all favourites.
|
// favouriteFuel parameter during fresh-widget default-config resolution,
|
||||||
@IntentParameterDependency<FuelBoardSmallWidgetConfigurationIntent>(
|
// and that resolution fails on-device — the whole default config fails
|
||||||
\.$favouriteFuel
|
// and the small widget strands on the skeleton placeholder. The picker
|
||||||
)
|
// now lists ALL favourites, each row labelled with its fuel; the
|
||||||
var smallIntent
|
// fuel-scoped filter was the dependency's only purpose. Configured
|
||||||
|
// Favourites-mode widgets are unaffected (stored configs skip the
|
||||||
|
// default resolution path entirely).
|
||||||
|
|
||||||
// LENIENT resolution: every stored identifier resolves to a
|
// LENIENT resolution: every stored identifier resolves to a
|
||||||
// WidgetFavourite (best-effort name lookup). NEVER return nil here — the
|
// WidgetFavourite (best-effort name lookup). NEVER return nil here — the
|
||||||
@@ -192,18 +194,13 @@ struct WidgetFavouriteQuery: EntityQuery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func suggestedEntities() async throws -> [WidgetFavourite] {
|
func suggestedEntities() async throws -> [WidgetFavourite] {
|
||||||
let favourites = FuelStore.loadFavourites()
|
// All favourites, each labelled with its fuel (no dependency available
|
||||||
let filtered: [FavouriteEntry]
|
// to filter by the chosen fuel — see the note above).
|
||||||
if let fuel = smallIntent?.favouriteFuel.fuel {
|
FuelStore.loadFavourites().map { entry in
|
||||||
filtered = favourites.filter { $0.fuel == fuel }
|
|
||||||
} else {
|
|
||||||
filtered = favourites
|
|
||||||
}
|
|
||||||
return filtered.map { entry in
|
|
||||||
WidgetFavourite(
|
WidgetFavourite(
|
||||||
fuel: entry.fuel,
|
fuel: entry.fuel,
|
||||||
stationID: entry.station.id,
|
stationID: entry.station.id,
|
||||||
stationName: entry.station.name
|
stationName: "\(entry.fuel.displayName) · \(entry.station.name)"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -271,8 +268,7 @@ struct FuelBoardWidgetConfigurationIntent: WidgetConfigurationIntent, WidgetConf
|
|||||||
// SMALL widget intent: same knobs as the list widget, PLUS a pinned-favourite
|
// SMALL widget intent: same knobs as the list widget, PLUS a pinned-favourite
|
||||||
// picker for Favourites sort (a small widget shows exactly ONE station, so the
|
// picker for Favourites sort (a small widget shows exactly ONE station, so the
|
||||||
// user chooses which favourite). Favourites mode swaps the Fuel row for a
|
// user chooses which favourite). Favourites mode swaps the Fuel row for a
|
||||||
// favourites-scoped one — only fuels with favourites are offered, and the
|
// favourites-scoped one — only fuels with favourites are offered. The
|
||||||
// chosen fuel dictates which favourites the Favourite picker lists. The
|
|
||||||
// pinned favourite wins when set; the fuel row picks the default favourite on
|
// pinned favourite wins when set; the fuel row picks the default favourite on
|
||||||
// a fresh widget. Distance stays hidden (a pinned station has no radius).
|
// a fresh widget. Distance stays hidden (a pinned station has no radius).
|
||||||
struct FuelBoardSmallWidgetConfigurationIntent: WidgetConfigurationIntent, WidgetConfigValues {
|
struct FuelBoardSmallWidgetConfigurationIntent: WidgetConfigurationIntent, WidgetConfigValues {
|
||||||
|
|||||||
Reference in New Issue
Block a user