Skip to content

refactor(repositories): migrate leaderboard URL state onto useDataTableParams hook#1041

Open
blinkeye-lcm wants to merge 2 commits into
entrius:testfrom
blinkeye-lcm:refactor/repositories-table-url-state
Open

refactor(repositories): migrate leaderboard URL state onto useDataTableParams hook#1041
blinkeye-lcm wants to merge 2 commits into
entrius:testfrom
blinkeye-lcm:refactor/repositories-table-url-state

Conversation

@blinkeye-lcm
Copy link
Copy Markdown
Contributor

Summary

TopRepositoriesTable now reads and writes its sort, filter, view-mode, and pagination state through the shared useDataTableParams hook, matching how TopMinersTable already works.

The hand-rolled syncToUrl callback, the isInitialMount ref, the page-reset useEffect with its eslint-disable react-hooks/exhaustive-deps suppression, and the URL-tracking useState slots all go away. A single useDataTableParams call plus a typed filtersConfig (search, status, view) covers the same surface in roughly a third of the code.

Display behavior is preserved for every interaction (sort, filter, search, pagination, view toggle). Two URL-representation changes are intentional and converge with TopMinersTable:

  • view=cards or view=list is always written after a toggle. The comment in TopMinersTable.tsx documents why dropping the param on the default value can leave the UI stuck on a stale localStorage value.
  • Trailing whitespace in the search box is trimmed at serialize time so the URL stays clean.

The cards-vs-list page-size asymmetry (10/25/50 vs 12/24/48) is handled by clamping the hook's raw value through the existing clampRowsForRepositoriesView helper for display, and by reflowing the URL on view toggle when the current value is invalid for the new view.

No user-visible bug is being fixed. The latent benefits include:

  • Future in-app navigation to /repositories?... from inside the SPA will be picked up by the table without a re-mount.
  • Other components can add query parameters to /repositories without the table clobbering them on its next write.
  • Cross-cutting URL-state improvements only need to land in useDataTableParams.

Related Issues

Closes #1040

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other (describe below)

Screenshots

No visible UI change. Verified locally that sort, status filter, search, pagination, and view toggle all behave as before. URL representation matches TopMinersTable for the two intentional convergence points noted above.

Checklist

  • New components are modularized/separated where sensible
  • Uses predefined theme (e.g. no hardcoded colors)
  • Responsive/mobile checked
  • Tested against the test API
  • npm run format and npm run lint:fix have been run
  • npm run build passes
  • Screenshots included for any UI/visual changes

@xiao-xiao-mao xiao-xiao-mao Bot added the refactor Code restructuring without behavior change label May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Code restructuring without behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consolidate TopRepositoriesTable URL state onto the shared useDataTableParams hook

1 participant