Skip to content

Fix infinite locate spinner + cached last-known geolocation - #8

Merged
Osyna merged 1 commit into
mainfrom
feature/cartoon-ui-skin
Aug 10, 2026
Merged

Osyna merged 1 commit into
mainfrom
feature/cartoon-ui-skin

Conversation

@Osyna

@Osyna Osyna commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Bug (reported)

Pressing Find in this area, then the locate button → spinner rolls forever.

Root cause: while a browser permission prompt sits undecided, getCurrentPosition callbacks never fire — the specified timeout does not apply. locating stayed true indefinitely.

Fix + feature

  • getFreshPosition() wraps the two-step fix with a hard 20 s guard (single-settle protected) — the spinner always ends
  • Last-known-position cache (localStorage, 7-day validity):
    • refs hydrate from it at boot → distances render immediately
    • locate() resolves instantly with the cached position (map flies right away, no spinner) while a fresh fix updates the marker in the background
    • if the fresh fix is > ~400 m from the cache, the map follows it
    • permission denied/unavailable now degrades gracefully to the cached position
  • Bonus from this branch: new navigation-arrow locate icon (fills with accent when active)

Verified with Playwright: permission-blocked context + cached position → instant fly to last position, spinner never sticks (0 after click, 0 after 4.5 s).

Bug: getCurrentPosition callbacks never fire while a browser permission
prompt sits undecided (no timeout applies), so the locate button could
spin forever — e.g. pressing 'Find in this area', dismissing the
prompt, then tapping locate.

- getFreshPosition() wraps the two-step fix attempt with a hard 20s
  guard that always ends the spinner (single-settle protected)

Feature: last-known-position cache (localStorage, 7d validity)
- Every good fix is persisted; refs hydrate from it at boot so
  distances render immediately
- locate() with a cache resolves INSTANTLY (map flies to the last
  position, no spinner) while a fresh fix updates the marker in the
  background; if the user moved > ~400m the map follows the fresh fix
- Permission denied/unavailable now degrades gracefully to the cached
  position instead of an error-only dead end
@Osyna
Osyna merged commit 7ef93c6 into main Aug 10, 2026
1 check passed
@Osyna
Osyna deleted the feature/cartoon-ui-skin branch August 10, 2026 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant