feat(vton): infinite scroll posts + drop whitelist + reset stale items#615
Merged
Conversation
- API: remove tops/bottoms/shoes subcategory whitelist that filtered posts to ~1 result. Whitelist already proved fragile once (#602/#609); rely on items.length>0 filter + post status instead. - API: cursor-based pagination via ?cursor=<created_at ISO>. Default listing branch returns nextCursor when the page filled; search and post_id branches always return nextCursor=null. Over-fetches limit*3 because items.length>0 is a JS filter, not SQL. - useVtonPostFetch: loadMore/hasMore/isLoadingMore, AbortController for in-flight cancel, dedupe across cursor boundary. - VtonItemPanel: IntersectionObserver sentinel (rootMargin 240px) inside the scroll container drives loadMore. - useVtonItemFetch: reset items state before fetching so a previously preloaded post's items don't linger in the grid while the next fetch is pending (visible when switching post -> items mode). - tests: 11 pass; new cases for cursor predicate, nextCursor emission, and cursor being ignored on search/post_id branches. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
items.length>0+ post status as the only gates is more durable.?cursor=<created_at ISO>on the default listing branch (search andpost_idbranches keep returningnextCursor=null). Server still over-fetcheslimit*3because theitems.length>0filter runs in JS, not SQL.useVtonPostFetchexposesloadMore/hasMore/isLoadingMore, cancels in-flight pages on close/query change, and dedupes across the cursor boundary.VtonItemPaneluses anIntersectionObserversentinel (rootMargin 240px) inside the scroll container to callloadMoreahead of the viewport edge.useVtonItemFetchnow resetsitemsbefore fetching, so a previously preloaded post's items no longer linger in the grid while the next category fetch is pending — this was visible when switching from post-selection mode back to the Items tab.Test plan
bunx vitest run app/api/v1/vton/posts— 11/11 pass (incl. new cursor cases)bunx tsc --noEmit— clean/lab/vton, confirm >1 post listed, scroll to trigger next page, then click a post → Items tab and verify the grid loads fresh items rather than the post's items.🤖 Generated with Claude Code