From 37cf47b3ddd683203eb1b928c85f82ba6ca849bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Fri, 13 Mar 2026 14:57:19 +0400 Subject: [PATCH] Properly handle place removals * Transition to OSM route or index instead of staying on ghost route/ID (closes sidebar if it was a custom place) * Ensure save button and lists are in the correct state --- app/components/place-details.gjs | 17 ++++-- app/components/place-lists-manager.gjs | 34 ++++++++++- app/services/storage.js | 11 ++++ tests/acceptance/navigation-test.js | 3 + tests/acceptance/search-test.js | 9 +++ .../components/place-details-test.gjs | 59 ++++++++++++++++++- 6 files changed, 124 insertions(+), 9 deletions(-) diff --git a/app/components/place-details.gjs b/app/components/place-details.gjs index f2dc19c..3738fb1 100644 --- a/app/components/place-details.gjs +++ b/app/components/place-details.gjs @@ -1,4 +1,5 @@ import Component from '@glimmer/component'; +import { service } from '@ember/service'; import { on } from '@ember/modifier'; import { htmlSafe } from '@ember/template'; import { humanizeOsmTag } from '../utils/format-text'; @@ -13,9 +14,14 @@ import { tracked } from '@glimmer/tracking'; import { action } from '@ember/object'; export default class PlaceDetails extends Component { + @service storage; @tracked isEditing = false; @tracked showLists = false; + get isSaved() { + return this.storage.isPlaceSaved(this.place.id || this.place.osmId); + } + get place() { return this.args.place || {}; } @@ -38,7 +44,7 @@ export default class PlaceDetails extends Component { @action startEditing() { - if (!this.place.createdAt) return; // Only allow editing saved places + if (!this.isSaved) return; // Only allow editing saved places this.isEditing = true; } @@ -276,7 +282,7 @@ export default class PlaceDetails extends Component { {{#if this.showLists}} {{/if}} - {{#if this.place.createdAt}} + {{#if this.isSaved}}