fix: add pagination and infinite scrolling for feature requests and roadmap (#5) - #17
Conversation
…oadmap (#5) - Support `limit`, `offset`, `columnId`, and `status` parameters in `FeedbackClient.fetchFeatureRequests` - Introduce reusable `useFeatureRequests` pagination hook with deduplication, cancellation, and in-place item mutation - Implement infinite scroll with `onEndReached` and footer loading indicator in `FeatureRequestsScreen` - Add query / filter reset and ensure pull-to-refresh restarts at page 0 - Add infinite scrolling and 'Showing N of M' pagination affordance to `RoadmapBoardScreen` - Add localized copy (`loadingMore`, `loadMore`, `showingCount`) across all 14 supported locales - Add test coverage for client serialization, backend pagination over 120 items, hook lifecycle, and locale dictionaries
…e state updater, and drop unsupported columnId/status params - Always clear isLoadingMoreRef/isLoadingMore in loadMore's finally block: refresh()/reload()/filter changes abort an in-flight load-more, and the previous conditional reset left the guard stuck at true, permanently disabling infinite scroll for the lifetime of the component. - Compute the dedup append count and short-page total clamp from itemsRef before calling setState. React invokes functional updaters during the next render (and twice under StrictMode), so mutating nextTotal inside the setItems updater was never visible to the following setTotal call. - Remove columnId/status from fetchFeatureRequests and useFeatureRequests: GET /api/v1/feature-requests only supports appKey/userToken/limit/offset/ versionId/q, so the server silently ignored these filters and returned unfiltered results. Neither screen passed them; AGENTS.md/README claims corrected accordingly. - Add regression tests for the guard reset and the short-page total clamp.
Code ReviewReviewed the full diff against I found three must-fix issues and pushed them in 2a61daf. Must-fix 1 —
|
Description
Closes #5
Both
FeatureRequestsScreenandRoadmapBoardScreenpreviously issued a single fetch request capped at 50 / 100 items with no mechanism to load subsequent pages, causing any items beyond the limit to be silently truncated.This PR introduces infinite scrolling and pagination support across the SDK, backed by a reusable
useFeatureRequestshook, footer loading indicators, filter/query reset behavior, and complete translations across all 14 supported locales.Key Changes
FeedbackClient.fetchFeatureRequests:limit,offset,columnId, andstatus.AGENTS.mdandREADME.md.Reusable Pagination Hook (
useFeatureRequests):items,total,hasMore,isLoading,isRefreshing,isLoadingMore).loadMore()with automatic page offset calculation.AbortControlleron unmount or subsequent calls.applyItemChange()to update items (such as optimistic upvoting) in-place without triggering full re-fetches.src/index.ts.FeatureRequestsScreen:useFeatureRequestshook.onEndReached(onEndReachedThreshold={0.4}) for smooth infinite scroll.loadingMorestring.RoadmapBoardScreen:onEndReachedinfinite scrolling per column.showingCount(shown, total)) with a "Load more" manual trigger.Internationalization (All 14 Locales):
loadingMoretocommon,featureRequests, androadmap.loadMoreandshowingCounttoroadmap.en)zhHans)zhHant)ja)ko)de)es)fr)it)pt)pl)no)tr)vi)Test Coverage:
test/pagination.test.tswith 7 comprehensive test cases:limit,offset,columnId,status).useFeatureRequestsinitial load, incremental appending, andhasMoredetection.applyItemChange.loadingMoreis populated across all 14 locales.Verification
npm test: All 71 tests passing cleanly (0 failures).npm run typecheck: Passed with 0 errors (tsc --noEmit).npm run build: ESM, CommonJS, and.d.tsdeclaration files compile without errors.npm run docs: TypeDoc generation succeeds without warnings.