From e6cef15dc82a61b1171d39806b978b15af7d0bae Mon Sep 17 00:00:00 2001 From: Bkk1234 Date: Sat, 24 Oct 2026 00:03:05 +0700 Subject: [PATCH] Fix 'stops near me' button: it was dead code stops.nearme.ts exported a default mount() but PageRuntime only invokes the default export of stops.init; this module was imported for its side effects and never called, so the button did nothing at all. - self-bind on import with a dataset.nearBound guard against double binding - retry up to ~2s while ATMap finishes loading - map.ts: re-enable the button after a successful lookup (it stayed disabled forever, so a second press was impossible) Verified with geolocation override at 14.5880,100.4530: first press renders the map plus 8 nearest stops with distances, button re-enables, second press works, and no duplicated network requests (2 per press). --- frontend/src/lib/ui/map.ts | 4 +++ frontend/src/lib/ui/stops.nearme.ts | 37 +++++++++++++++++++++---- frontend/src/styles/responsive.css | 43 +++++++++++++++++++++++++++++ frontend/tsconfig.tsbuildinfo | 2 +- 4 files changed, 79 insertions(+), 7 deletions(-) diff --git a/frontend/src/lib/ui/map.ts b/frontend/src/lib/ui/map.ts index 3d8cf68..110fbb3 100644 --- a/frontend/src/lib/ui/map.ts +++ b/frontend/src/lib/ui/map.ts @@ -602,6 +602,10 @@ window.ATMap = (function () { items.sort(function (a, b) { return a.d - b.d; }); var near = items.slice(0, opts.limit || 8); renderNear(resultEl, near, me, opts); + /* ปลดล็อกปุ่มหลังหาป้ายเสร็จ — ผู้ใช้เดินไปที่ใหม่แล้วกดซ้ำได้ */ + button.disabled = false; + }).catch(function () { + button.disabled = false; }); }, function () { button.disabled = false; diff --git a/frontend/src/lib/ui/stops.nearme.ts b/frontend/src/lib/ui/stops.nearme.ts index 497a8e4..070c41c 100644 --- a/frontend/src/lib/ui/stops.nearme.ts +++ b/frontend/src/lib/ui/stops.nearme.ts @@ -1,9 +1,34 @@ // @ts-nocheck /* Ported from the inline