Skip to content

implement automatic journal pagination #2058

New issue

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

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

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

upsuper
Copy link
Contributor

@upsuper upsuper commented Jul 6, 2025

This PR implements automatic pagination for the journal report as a solution to improve performance opening journal page.

At high level, it involves

  • journal.html handles page parameter in request.
    • When it's not set, and the total number of entries is larger than a per-page number, it assign the total number of pages to paginated attribute on the <fava-journal> custom element.
    • When it's set, it slices the entries and only render the given page of the entries.
  • FavaJournal checks if there is paginated attribute set, it automatically starts fetching all the remaining pages and append them to the <ol>.

With pagination, it's desirable for entries that show up first to be loaded first. Journal table currently renders in date ascendant but the default and most commonly useful order is date descendant, so this PR also changes the rendering order from asc to desc and negate the sort value.

1000 is used as the fixed per-page number because based on my local testing, it is a reasonable balance between initial delay vs. number of pages. It could potentially go up to 2,000.

@upsuper
Copy link
Contributor Author

upsuper commented Jul 25, 2025

@yagebu Would you mind taking a look at the high level approach? If you think this is not going towards the right direction, I can definitely try a different approach.

Several alternatives I can think of:

  • Utilize some JSON API endpoint (as oppose to paginating on journal.html).
  • Use explicit pagination (i.e. showing page indicators underneath).
  • Use lazy pagination (i.e. only load remaining when scrolling to it).

Also it may be useful to take into account the sorting preference. But I think that would significantly increased the complexity without adding much value, because majority of people would likely just default to sorting by date in descending order.

@deirn
Copy link

deirn commented Jul 26, 2025

I implemented lazy rendering using virtual lists on the client. #2080

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