Skip to content

Conversation

@kevinw8765
Copy link

@kevinw8765 kevinw8765 commented Jun 24, 2025

Related Tickets & Documents

Fixes: #132

Description

  • Previously, the “Load More Posts” button would disappear whenever loading was true, leaving users without feedback.
  • This change ensures the button remains visible at all times and displays a spinner while fetching more posts.
  • Also adds a scroll listener to prefetch the next batch when the user scrolls within 500px of the bottom.

Changes

  • Removed !loading check from the showLoadMore condition.
  • Wrapped loadMoreInBackground in useCallback to stabilize dependencies.
  • Added a window.scroll listener in a useEffect to trigger background prefetch when near page bottom.

Type of Change

  • Chore (maintenance, refactoring, tooling updates)
  • Bug fix (non-breaking change that fixes an issue)
  • New feature (change that adds functionality)
  • Breaking Change (may require updates in existing code)
  • UI improvement (visual or design changes)
  • Performance improvement (optimization or efficiency enhancements)
  • Documentation update (changes to README, guides, etc.)
  • CI (updates to continuous integration workflows)
  • Revert (undo a previous commit or merge)

Testing

  • Manually scrolled to bottom on the blog index page: the button remains visible and shows a spinner while loading.
  • Clicked “Load More Posts” multiple times: buffer draining and fetch logic works without hiding the button.
  • Verified no console errors in both index and non-index contexts.

Environment and Dependencies

  • New Dependencies: N/A
  • Configuration Changes: N/A

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation (if needed)
  • I have added corresponding tests (if applicable)
  • I have run the build command to ensure there are no build errors
  • My changes have been tested across relevant browsers/devices
  • For UI changes, I've included visual evidence of my changes

Signed-off-by: Kevin Wong <[email protected]>
@amaan-bhati
Copy link
Member

Hey @kevinw8765 Thanks for raising this pr, can you please share a preview of the same? A screenshot also works.

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.

2 participants