ayushagg31 / Trellis

A simplified Trello clone built with React, Redux, Node, Express and MongoDB.
https://trellis-app.herokuapp.com
GNU General Public License v3.0
126 stars 54 forks source link

feat(activites): add pagination to activity list #59

Closed ColinFrick closed 3 years ago

ColinFrick commented 3 years ago

Description Adds a "Load more" button to the activity list. By default only the 10 newest activities are displayed in the side bar, older activities can be loaded with the new button.

Fixes #12

Type of change

Checklist

Expected Outcome Peek 2020-10-22 14-50

Additional Information I extended the activities API with last and limit query parameters. To ensure consistency when retrieving more activities (f.e. when someone else created a new activity while on the page) I use the id of the last activity visible, instead of just skipping 10 items.

The API also returns a new "X-Has-More" header flag, which indicates if more activities are available. I had "X-Total-Count" first, but I think this is a better indicator if there are really more activities to load. Additionally I can set that flag with loading limit + 1, instead of additionally executing Activity.countDocuments({ boardId: _id }).

ayushagg31 commented 3 years ago

Thanks @ColinFrick. Woah, you created a trellis board for this PR, that is awesome😅, I'll review it over weekend.

ayushagg31 commented 3 years ago

One of the best PR on this repo, thanks for the submission @ColinFrick