From 0fee9ad2ddef790c8d885be77a0dd874b7fce1b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Wed, 21 Jan 2026 19:15:38 +0700 Subject: [PATCH] Link to bookmarked places from nearby places --- app/templates/application.gjs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/app/templates/application.gjs b/app/templates/application.gjs index afcc754..847acde 100644 --- a/app/templates/application.gjs +++ b/app/templates/application.gjs @@ -28,15 +28,26 @@ export default class ApplicationComponent extends Component { @action showPlaces(places, selectedPlace = null) { + // Helper to resolve a place to its bookmark if it exists + const resolvePlace = (p) => { + if (!p) return null; + // We use the OSM ID to check if we already have this place saved + const saved = this.storage.findPlaceById(p.osmId); + return saved || p; + }; + + const resolvedSelected = resolvePlace(selectedPlace); + const resolvedPlaces = places ? places.map(resolvePlace) : []; + // If we have a specific place, transition to the route - if (selectedPlace) { + if (resolvedSelected) { // Pass the FULL object model to avoid re-fetching! // The Route's serialize() hook handles URL generation. - this.router.transitionTo('place', selectedPlace); + this.router.transitionTo('place', resolvedSelected); this.nearbyPlaces = null; // Clear list when selecting specific - } else if (places && places.length > 0) { + } else if (resolvedPlaces && resolvedPlaces.length > 0) { // Show list case - this.nearbyPlaces = places; + this.nearbyPlaces = resolvedPlaces; this.router.transitionTo('index'); } }