Refactor/pagination handlers#111
Draft
RaduCristianPopescu wants to merge 7 commits intodevelopmentfrom
Draft
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the Messages component to replace the "Load More" button with a proper pagination system, improving user experience by allowing navigation between pages of messages.
- Replaced load more functionality with page-based navigation
- Added caching mechanism for fetched pages
- Updated backend API response to include total count and posts per page
- Added comprehensive pagination controls with Previous/Next buttons and page indicators
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| src/backend/parts/Messages.js | Replaced LoadMore component with SimplePagination, refactored state management to use page-based caching, and updated UI layout |
| inc/API.php | Modified API response to return total posts count and posts per page instead of boolean "more" flag |
src/backend/parts/Messages.js
Outdated
Comment on lines
177
to
185
| const startIndex = totalPosts - ( currentPage - 1 ) * postsPerPage; | ||
| const endIndex = Math.max( startIndex - actualPostsOnPage + 1, 1 ); | ||
|
|
||
| return ( | ||
| <div className="col-span-6 xl:col-span-2 border-r-gray-300 border-r-[0.5px] border-solid max-h-[672px] overflow-scroll"> | ||
| <div className="flex items-center justify-between py-4 px-2"> | ||
| <div className="flex items-center gap-3"> | ||
| <span className="text-sm text-gray-600"> | ||
| { startIndex }-{ endIndex } { __( 'of', 'hyve-lite' ) } { } | ||
| { totalPosts } { __( 'rows', 'hyve-lite' ) } |
There was a problem hiding this comment.
The startIndex and endIndex calculation is confusing and may display incorrect ranges. For pagination, it's more intuitive to show the actual item numbers being displayed (e.g., '11-20 of 100') rather than calculating from totalPosts backwards.
Suggested change
| const startIndex = totalPosts - ( currentPage - 1 ) * postsPerPage; | |
| const endIndex = Math.max( startIndex - actualPostsOnPage + 1, 1 ); | |
| return ( | |
| <div className="col-span-6 xl:col-span-2 border-r-gray-300 border-r-[0.5px] border-solid max-h-[672px] overflow-scroll"> | |
| <div className="flex items-center justify-between py-4 px-2"> | |
| <div className="flex items-center gap-3"> | |
| <span className="text-sm text-gray-600"> | |
| { startIndex }-{ endIndex } { __( 'of', 'hyve-lite' ) } { } | |
| { totalPosts } { __( 'rows', 'hyve-lite' ) } | |
| const startIndex = ( currentPage - 1 ) * postsPerPage + 1; | |
| const endIndex = Math.min( startIndex + postsPerPage - 1, totalPosts ); | |
| return ( | |
| <div className="flex items-center justify-between py-4 px-2"> | |
| <div className="flex items-center gap-3"> | |
| <span className="text-sm text-gray-600"> | |
| { startIndex }-{ endIndex } { __( 'of', 'hyve-lite' ) } { totalPosts } { __( 'rows', 'hyve-lite' ) } |
Soare-Robert-Daniel
requested changes
Jul 28, 2025
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
Remove the Load More button, now there is pagination.
NOTE
The actual postPerPage value is set to 10 for pro users, this was only for demo
Will affect visual aspect of the product
YES
Screenshots
Recording.mp4
Closes https://github.com/Codeinwp/hyve/issues/81