style(activists): keep showing old results when query changes#322
style(activists): keep showing old results when query changes#322
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughPreserves table column/sort state during placeholder refetches on the activists page, surfaces a stale visual state to the table, shows a bottom "Loading updated results..." banner while placeholder data is active, and suppresses load-more behavior until fresh data arrives. Changes
Sequence Diagram(s)sequenceDiagram
participant Page as ActivistsPage
participant Query as useInfiniteQuery
participant Table as ActivistTable
participant LoadMore as LoadMoreTrigger
participant Banner as LoadingBanner
Page->>Query: fetch / refetch (infinite)
Query-->>Page: returns placeholderData (isPlaceholderData = true)
Page->>Page: retain settledTableState (columns, sort)
Page->>Table: render with tableColumns/tableSort, isStale=true
Page->>LoadMore: suppress trigger (do not load next page)
Page->>Banner: show fixed "Loading updated results..." with spinner
Query-->>Page: returns final fresh data (isPlaceholderData = false)
Page->>Page: update settledTableState with new selection/sort
Page->>Table: render fresh data with isStale=false
Page->>LoadMore: re-enable trigger
Page->>Banner: hide loading banner
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@frontend-v2/src/app/`(authed)/activists/activists-page.tsx:
- Around line 290-302: The placeholderData is causing stale cursors to be used
by getNextPageParam while the query is in isPlaceholderData state; fix this by
tagging the placeholder response with a sentinel (e.g., add a boolean property
like __isPlaceholder = true on the object returned from placeholderData) and
then update getNextPageParam to detect lastPage.__isPlaceholder and return
undefined when set (thereby disabling next-page pagination while placeholder
data is displayed); also ensure any UI code calling fetchNextPage or using
isPlaceholderData checks that __isPlaceholder is not true before triggering
load-more.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 5b415983-05b7-48f5-a202-7cf1418445ca
📒 Files selected for processing (2)
frontend-v2/src/app/(authed)/activists/activists-page.tsxfrontend-v2/src/app/(authed)/activists/activists-table.tsx
1c697ff to
30505c2
Compare
30505c2 to
060d256
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@frontend-v2/src/app/`(authed)/activists/activists-table.tsx:
- Line 90: When isStale is true the table headers remain interactive and can
change the stale sort/visibleColumns; make header controls inert while isStale
to prevent clicks from mutating stale state. Update the header rendering/handler
logic (the component that reads isStale, visibleColumns, and sort and attaches
the click handler used for header buttons) to short-circuit pointer events and
onClick behavior when isStale is true (e.g., disable the sorting button and
ignore click events), and ensure the same guard is applied in the codepaths
referenced around isStale and lines handling visibleColumns/sort so rapid clicks
cannot compute a new sort from stale state.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 6bcbab49-2f29-4024-8dc0-35745ef0a19a
📒 Files selected for processing (2)
frontend-v2/src/app/(authed)/activists/activists-page.tsxfrontend-v2/src/app/(authed)/activists/activists-table.tsx
Summary by CodeRabbit