Skip to content

fix(reader): Preload adjacent chapters when current chapter has a single page#641

Closed
solstxce wants to merge 1 commit into
null2264:masterfrom
solstxce:fix/617-reader-stuck-single-page-prev-chapter
Closed

fix(reader): Preload adjacent chapters when current chapter has a single page#641
solstxce wants to merge 1 commit into
null2264:masterfrom
solstxce:fix/617-reader-stuck-single-page-prev-chapter

Conversation

@solstxce

Copy link
Copy Markdown

Closes #617

Summary

When a chapter consists of exactly one page, the reader never scrolls onto a ChapterTransition page, so the adjacent-chapter preload that the transition page normally triggers never runs. Because the lone page settles at idle with the same first/last index, swiping backwards out of the 1-page chapter cannot reach a loaded previous chapter, leaving the reader stuck (the forward direction was already handled, but only for the next chapter).

Changes

  • PagerViewerAdapter.kt: Track a prevTransition (ChapterTransition.Prev) mirroring the existing nextTransition, so the previous-adjacent chapter is reachable for inspection.
  • PagerViewer.kt: Move the single-page adjacent-chapter preload out of the isIdle-only path into setChaptersDoubleShift so it runs regardless of which code path sets the chapters, and preload the previous chapter in addition to the next one.

This lets the user swipe out of a 1-page chapter in either direction, since the preceding chapter is preloaded and the "Load Previous Chapter" transition can proceed.

Notes

  • The previous fix in commit 1040eccd7e "Fix chapter transition setting for one page chapters" only preloaded nextTransition?.to, and only when chapters arrived while the pager was non-idle. This regressed for the backward direction and for the idle path.
  • Builds on top of the existing preload mechanism (requestPreloadChapter -> ReaderViewModel.preload -> Event.ReloadViewerChapters), so once the previous chapter loads the viewer is updated as usual.

Testing

Manual repro from the issue: open a manga, ensure the previous chapter has exactly 1 page, read the current chapter, swipe back into the 1-page chapter, then swipe back again. The reader should now trigger the "Load Previous Chapter" transition instead of getting stuck. Build/CI verification via ./gradlew assembleStandardRelease + unit tests.

…gle page

When a chapter consists of a single page, the reader never scrolls onto a
ChapterTransition page, so the adjacent-chapter preload that the transition
page normally triggers never runs. This left the reader unable to swipe
backwards out of a 1-page chapter (issue null2264#617).

Track a prevTransition on PagerViewerAdapter (mirroring nextTransition).
Move the single-page adjacent preload out of the isIdle-only path into
setChaptersDoubleShift so it runs in both code paths, and preload the
previous chapter in addition to the next one either direction can
swipe out of the chapter.
@solstxce
solstxce force-pushed the fix/617-reader-stuck-single-page-prev-chapter branch from e328bd5 to 50c9eb7 Compare July 16, 2026 04:42
@solstxce

Copy link
Copy Markdown
Author

Closing to recreate with corrected commit authorship.

@solstxce solstxce closed this Jul 16, 2026
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.

Reader gets stuck when swiping back through a previous chapter that only has 1 page

1 participant