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
|
||||
// AppEntity so only fuels that ACTUALLY have favourites appear in the picker —
|
||||
// mirrors the app's Favourites tab capsules. The chosen fuel dictates which
|
||||
// favourites the Favourite picker offers (see WidgetFavouriteQuery).
|
||||
// mirrors the app's Favourites tab capsules. (The Favourite picker itself is
|
||||
// fuel-independent now — see WidgetFavouriteQuery.)
|
||||
struct FavouriteFuel: AppEntity, Identifiable, Hashable, Codable {
|
||||
let fuel: FuelType
|
||||
|
||||
@@ -149,13 +149,15 @@ struct WidgetFavourite: AppEntity, Identifiable, Hashable, Codable {
|
||||
}
|
||||
|
||||
struct WidgetFavouriteQuery: EntityQuery {
|
||||
/// Reads the small intent's Favourite Fuel parameter: the Favourite picker
|
||||
/// only offers THAT fuel's favourites (requirement: the chosen fuel
|
||||
/// dictates the list). Nil (medium widget / fresh sheet) → all favourites.
|
||||
@IntentParameterDependency<FuelBoardSmallWidgetConfigurationIntent>(
|
||||
\.$favouriteFuel
|
||||
)
|
||||
var smallIntent
|
||||
// NO @IntentParameterDependency: the dependent-picker machinery resolves
|
||||
// the favourite parameter through the (hidden, in Cheapest mode)
|
||||
// favouriteFuel parameter during fresh-widget default-config resolution,
|
||||
// and that resolution fails on-device — the whole default config fails
|
||||
// and the small widget strands on the skeleton placeholder. The 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 (stored configs skip the
|
||||
// default resolution path entirely).
|
||||
|
||||
// LENIENT resolution: every stored identifier resolves to a
|
||||
// WidgetFavourite (best-effort name lookup). NEVER return nil here — the
|
||||
@@ -192,18 +194,13 @@ struct WidgetFavouriteQuery: EntityQuery {
|
||||
}
|
||||
|
||||
func suggestedEntities() async throws -> [WidgetFavourite] {
|
||||
let favourites = FuelStore.loadFavourites()
|
||||
let filtered: [FavouriteEntry]
|
||||
if let fuel = smallIntent?.favouriteFuel.fuel {
|
||||
filtered = favourites.filter { $0.fuel == fuel }
|
||||
} else {
|
||||
filtered = favourites
|
||||
}
|
||||
return filtered.map { entry in
|
||||
// All favourites, each labelled with its fuel (no dependency available
|
||||
// to filter by the chosen fuel — see the note above).
|
||||
FuelStore.loadFavourites().map { entry in
|
||||
WidgetFavourite(
|
||||
fuel: entry.fuel,
|
||||
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
|
||||
// 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
|
||||
// favourites-scoped one — only fuels with favourites are offered, and the
|
||||
// chosen fuel dictates which favourites the Favourite picker lists. The
|
||||
// favourites-scoped one — only fuels with favourites are offered. The
|
||||
// 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).
|
||||
struct FuelBoardSmallWidgetConfigurationIntent: WidgetConfigurationIntent, WidgetConfigValues {
|
||||
|
||||
Reference in New Issue
Block a user