ReviewOS

stacks/wildloop

Unify fragile route-param extraction across [id] detail pages

#987
Closed glennmichael123 opened this 9 days ago ·
9 days ago

Problem

Detail pages read different undocumented globals: activity/[id].stx uses window.__routeParams?.id ?? 1, trail/[id].stx uses window.stx?._rp?.id ?? window.__stx_rp?.id ?? 0, territory/[id].stx uses window.__routeParams?.id ?? 1. If the router changes they silently load id 1/0.

Acceptance

  • One useRouteParam(name) helper used by all detail pages.
  • No silent fallback to a wrong id.
8 days ago

Done in baceaa3.

New resources/composables/useRouteParam.ts resolves the [id] param from any known router global (__routeParams, stx._rp, __stx_rp), falls back to the URL's trailing path segment, and returns null when it genuinely can't resolve a positive id.

All four detail pages — activity / trail / territory / athlete — were each reading a different undocumented global and silently falling back to id 1 or 0. They now all use the helper with a -1 no-match sentinel, so an unresolved param renders each page's existing 'not found' state instead of loading a valid-but-wrong record. Confirmed all four not-found branches trigger correctly under the sentinel (adversarial review, 0 findings).

Sign in to comment on this issue.