Skip to content

Allow details and slideshow to load in background#645

Open
auralewd wants to merge 6 commits into
khoadng:masterfrom
auralewd:master
Open

Allow details and slideshow to load in background#645
auralewd wants to merge 6 commits into
khoadng:masterfrom
auralewd:master

Conversation

@auralewd

@auralewd auralewd commented Apr 15, 2026

Copy link
Copy Markdown

Goal: allow background fetching of more pages of posts while scrolling through

Solution: To avoid redesigning the entire way posts are managed, i've implemented a "lazy list" class, DetailsPostsListing<T> extends ListBase<T> which replaces the simple List<T extends Post> which was passed around before. It still supports storing a simple List for cases where a controller isn't available (i haven't tried very hard).

To make the UI work with dynamic updates, i introduced multiple new ValueListenableBuilder listening to the DetailsPostsListing.dynlen which is a ValueNotifier<int> for changes in the length of available items.

Notes:

  • The new classes currently live in lib/core/posts/details/src/routes/details_route_context.dart as the main class, DetailsPostsListing<T> is a field on the DetailsRouteContext class.
  • DetailsPostsListing internally stores List<dynamic>/PostGridController<dynamic> to avoid having to specify 2 generics. The output type T is able to be changed by listingMap((i) => i as SpecificPost) to replicate the controller.items.map((i) => i as SpecificPost).toList() behaviour which was used in a few places.
  • DetailsPostsListing delegates the handling of infinite/pagination modes to a corresponding _ListingStrategy
  • _InfiniteStrategy is pretty straightforward: fetch new posts when near the end, and update the length
  • _PaginatedStrategy essentially implements a kind of "infinite scrolling" on top of the underlying paginated nature of PostGridController. For this it stores all seen posts, both forwards and backwards, adding to them whenever approaching one of the edges of the loaded state. Because this means that it has to add posts before the current ones, i calls out to PostDetailsPageViewController to jump to the correct post (previous post index + new items length) so the UI visually stays on the post the user was looking at while extending to the left.
  • SlideshowController has gotten a _handleTotalPagesChanged which calls a new method withUpdatedTotalPages on SlideshowState. This is implemented by updating the totalPages, the currentPage if necessary (fewer posts), and the randomSequence if its used. The randomSequence is kept as-is, with the new pages posts added on top. That means in effect it will randomize each page internally but it won't randomize across pages.

Status:

  • background loading
    • when infinite scrolling selected
      • for post details
      • for slideshow
    • when paginated is selected
      • for post details
      • for slideshow

@CLAassistant

CLAassistant commented Apr 15, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@auralewd auralewd marked this pull request as ready for review April 15, 2026 21:05
@auralewd

Copy link
Copy Markdown
Author

Note: so far i've only tested the linux build, i haven't set up/installed the tools to test on my phone.

@khoadng

khoadng commented Apr 27, 2026

Copy link
Copy Markdown
Owner

Infinite mode looks good but pagination is buggy, if you swipe and switch to next page, then you go back then tap on one of the image, it will back to previous page again.

@khoadng

khoadng commented Apr 27, 2026

Copy link
Copy Markdown
Owner

I think for paginated mode, we should have a same UX as the listing page where switching page is a dedicated user action not auto switch, like swiping on the last item will pull out an load next indicator then if user release, we switch page.

@auralewd

Copy link
Copy Markdown
Author

Hey, as you can see i've not updated this. Feel free to take the code and change it how you wish, or not at all if you don't want to. It'd still be cool to see this feature but i honestly haven't been using boorusama that much

@khoadng

khoadng commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Thanks for the update, i'm planning to add this changes together with your blacklist redesign in the next version.

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.

3 participants