You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clicking the swap button on the compare page should only swap the two already-loaded users in the UI and update the URL order. Currently it can trigger a fresh /api/compare request after the URL changes, even though the same two users are already available locally.
Context
components/compare-form.tsx correctly uses type="button" for the swap action, so this is not a form-submit issue.
components/home-page-client.tsx swaps username1/username2, calls router.push(...), and then swaps data.user1/data.user2 locally.
The useEffect that watches searchParams runs after the router.push and calls syncToUrl(...).
syncToUrl(...) builds a new fetch key with the reversed username order, so it does not match lastFetchedKeyRef.current and calls handleCompare(..., { updateUrl: false }), causing an unnecessary refetch.
Tasks
Make compare fetch deduplication treat swapped username pairs as the same comparison when selected languages are unchanged, or track a swap-only URL update so syncToUrl does not refetch.
Ensure swapUsers() preserves selected language query params when updating the URL.
Keep the local data swap behavior so the UI updates immediately without loading state.
Add a regression test or interaction test that verifies clicking swap does not call /api/compare again.
Tip
🚀 Want to contribute?
Comment assign me to be automatically assigned to this issue via our GitHub Actions bot. Happy coding! ✨
Clicking the swap button on the compare page should only swap the two already-loaded users in the UI and update the URL order. Currently it can trigger a fresh
/api/comparerequest after the URL changes, even though the same two users are already available locally.Context
components/compare-form.tsxcorrectly usestype="button"for the swap action, so this is not a form-submit issue.components/home-page-client.tsxswapsusername1/username2, callsrouter.push(...), and then swapsdata.user1/data.user2locally.useEffectthat watchessearchParamsruns after therouter.pushand callssyncToUrl(...).syncToUrl(...)builds a new fetch key with the reversed username order, so it does not matchlastFetchedKeyRef.currentand callshandleCompare(..., { updateUrl: false }), causing an unnecessary refetch.Tasks
syncToUrldoes not refetch.swapUsers()preserves selected language query params when updating the URL./api/compareagain.Tip
🚀 Want to contribute?
Comment
assign meto be automatically assigned to this issue via our GitHub Actions bot. Happy coding! ✨