refactor(repositories): migrate leaderboard URL state onto useDataTableParams hook#1041
Open
blinkeye-lcm wants to merge 2 commits into
Open
refactor(repositories): migrate leaderboard URL state onto useDataTableParams hook#1041blinkeye-lcm wants to merge 2 commits into
blinkeye-lcm wants to merge 2 commits into
Conversation
…es-table-url-state
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TopRepositoriesTablenow reads and writes its sort, filter, view-mode, and pagination state through the shareduseDataTableParamshook, matching howTopMinersTablealready works.The hand-rolled
syncToUrlcallback, theisInitialMountref, the page-resetuseEffectwith itseslint-disable react-hooks/exhaustive-depssuppression, and the URL-trackinguseStateslots all go away. A singleuseDataTableParamscall plus a typedfiltersConfig(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=cardsorview=listis always written after a toggle. The comment inTopMinersTable.tsxdocuments why dropping the param on the default value can leave the UI stuck on a stale localStorage value.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
clampRowsForRepositoriesViewhelper 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:
/repositories?...from inside the SPA will be picked up by the table without a re-mount./repositorieswithout the table clobbering them on its next write.useDataTableParams.Related Issues
Closes #1040
Type of Change
Screenshots
No visible UI change. Verified locally that sort, status filter, search, pagination, and view toggle all behave as before. URL representation matches
TopMinersTablefor the two intentional convergence points noted above.Checklist
npm run formatandnpm run lint:fixhave been runnpm run buildpasses