Skip to content

refactor: extract pagination helper to reduce code duplication#80

Open
odysseus0 wants to merge 1 commit intosteipete:mainfrom
odysseus0:odysseus0/pagination-helper
Open

refactor: extract pagination helper to reduce code duplication#80
odysseus0 wants to merge 1 commit intosteipete:mainfrom
odysseus0:odysseus0/pagination-helper

Conversation

@odysseus0
Copy link
Contributor

Summary

  • Add paginateItems() method to TwitterClientBase that encapsulates common pagination loop logic
  • Refactor 5 paged methods across 4 files to use the new helper
  • Net reduction of ~160 lines while improving maintainability

Changes

The helper consolidates:

  • Deduplication via seen set
  • Cursor-based pagination loop
  • Query ID refresh on 404/validation errors
  • maxPages limit handling
  • nextCursor tracking for resumable pagination

Refactored methods:

  • getLikesPaged (twitter-client-timelines.ts)
  • getBookmarksPaged (twitter-client-timelines.ts)
  • getBookmarkFolderTimelinePaged (twitter-client-timelines.ts)
  • searchPaged (twitter-client-search.ts)
  • getListTimelinePaged (twitter-client-lists.ts)

Test plan

  • All 421 tests pass locally
  • TypeScript type checking passes
  • CI passes

🤖 Generated with Claude Code

Add paginateItems() method to TwitterClientBase that encapsulates
the common pagination loop logic shared across 5 paged methods.
This consolidates deduplication, cursor handling, maxPages limits,
and query ID refresh on 404 errors into a single reusable helper.

Refactored methods:
- getLikesPaged (twitter-client-timelines.ts)
- getBookmarksPaged (twitter-client-timelines.ts)
- getBookmarkFolderTimelinePaged (twitter-client-timelines.ts)
- searchPaged (twitter-client-search.ts)
- getListTimelinePaged (twitter-client-lists.ts)

Net reduction of ~160 lines while improving maintainability.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant