Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Paginate expenses #30

Closed
scastiel opened this issue Jan 8, 2024 · 6 comments
Closed

Paginate expenses #30

scastiel opened this issue Jan 8, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@scastiel
Copy link
Member

scastiel commented Jan 8, 2024

The expense list can be slow when displaying several hundreds of transactions. It would make sense to paginate transactions, i.e. either:

  1. Display the first X transactions by default, and then a “Show more” button
  2. Display an actual pagination, i.e. show page one by default and offer the option to go to a random page.

My preference is on option 1, but open to discussion.

@scastiel scastiel added the enhancement New feature or request label Jan 8, 2024
@justcallmelarry
Copy link
Contributor

I'll add that i like option 1 as well. As long as you can search and export I don't think you really need option 2.

@manuerwin
Copy link

Agree, option 1 would work for me so long as search works well

@shynst
Copy link
Contributor

shynst commented Feb 13, 2024

I would prefer a technique called "infinite scroll" over traditional "old-school" pagination.

Infinite Scroll is a technique that automatically adds the next page as the user scrolls down through content, more content is loaded. User don’t need to wait for pages to preload. So infinite scroll can provide user a better experience.

https://blog.logrocket.com/3-ways-implement-infinite-scroll-react/

@manuerwin
Copy link

I would prefer a technique called "infinite scroll" over traditional "old-school" pagination.
Infinite Scroll is a technique that automatically adds the next page as the user scrolls down through content, more content is loaded. User don’t need to wait for pages to preload. So infinite scroll can provide user a better experience.

I change my vote to this "Option 3" :)

shynst added a commit to shynst/spliit that referenced this issue Feb 18, 2024
- display only this year's entries by default
- a "Show more" button reveals all expenses
shynst added a commit to shynst/spliit that referenced this issue Feb 18, 2024
- display only this year's entries by default
- a "Show more" button reveals all expenses
@shynst
Copy link
Contributor

shynst commented Feb 18, 2024

Here is my implementation of "option 3: infinite scroll": #95

scastiel added a commit that referenced this issue May 30, 2024
* Extract ExpenseCard vom ExpenseList

* Implement simple pagination of expenses (see #30)

- display only this year's entries by default
- a "Show more" button reveals all expenses

* Turn getPrisma() into constant "prisma"

- getPrisma() is not async and doesn't need to be awaited
- turn getPrisma() into exported constant "prisma"

* Select fields to be returned by getGroupExpenses()

- make JSON more concise and less redundant
- some properties were removed (i.e.instead of "expense.paidById" use "expense.paidBy.id")

* Remove "participants" from ExpenseCard

- no need to search for participant by id to get it's name
- name property is already present in expense

* Add option to fetch a slice of group expenses

- specify offset and length to get expenses for [offset, offset+length[
- add function to get total number of group expenses

* Add api route for client to fetch group expenses

* Remove "Show more" button from expense list

* Implement infinite scroll

- in server component Page
  - only load first 200 expenses max
  - pass preloaded expenses and total count

- in client component ExpenseList, if there are more expenses to show
  - test if there are more expenses
  - append preloading "skeletons" to end of list
  - fetch more expenses when last item in list comes into view
  - after each fetch increase fetch-length by factor 1.5
    - rationale: db fetch usually is not the issue here, the longer the list gets, the longer react needs to redraw

* Use server action instead of api endpoint

* Fixes

---------

Co-authored-by: Sebastien Castiel <sebastien@castiel.me>
@ChristopherJohnston
Copy link
Contributor

@scastiel I think this can now be closed after the #95 merge

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants