Repository navigation
fix(core): navigate next into the next book's intro - #464
Conversation
getAdjacentChapter skipped the next book's intro going forward but visited it going back, so previous(next(x)) did not return x and BibleReader's next button never reached an intro. Next from a book's last chapter now goes to the next book's intro when it has one, matching Swift's goToNextChapter. Reverses the two tests from #168 that asserted the skip and adds a round-trip check over every chapter and intro. YPE-6400 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 272e3a4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
camrun91
left a comment
There was a problem hiding this comment.
Hi! Thank you for this fix. The logic is correct, and it agrees with Swift and Kotlin. All CI checks pass, and the tests fail on the old code, so they catch the bug.
I have one required change:
Update the JSDoc for getAdjacentChapter (packages/core/src/getAdjacentChapter.ts:10-18)
getAdjacentChapter is public API. Core exports it, and UI exports it again. This PR changes the value that it returns, but the JSDoc still says only "Computes the next or previous chapter across book boundaries." Our review guidelines tell us to document API changes with JSDoc (docs/review-guidelines.md).
Please add the intro behavior. For example:
Reading order is each book's intro (when
book.introis present), then its numbered chapters.nextfrom the last chapter of a book returns the intro of the next book when it has one. If not, it returns chapter 1.previousfrom chapter 1 returns the intro of the book.
After you make this change, I can approve. Thanks again!
…-chapter-next-intro
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @camrun91. Added the reading-order JSDoc to |
…-chapter-next-intro
|
@arinthros I am going to merge this so it can make it in the release I am about to do. |
Why
getAdjacentChapterhandles book intros differently in each direction.previousfrom chapter 1 of a book with an intro goes to that intro, butnextfrom the last chapter of the previous book skips it and goes to chapter 1. So next and previous are not inverses, and a reader paging forward inBibleReadernever reaches an intro:The Swift reader goes to the intro:
goToNextChapterinBibleReaderViewModel+Navigation.swiftmoves to the next book withshowBookIntro = truewhen that book has an intro.Jira: YPE-6400
What changed
introwhen it has one; otherwise its first numbered chapter, as before.next chapter cross-book, skipping introandcross-book next skips intro in chapters array of next book).nextreturns the following position andpreviousthe one before.Scope
next. Within-book navigation,previous, and the Bible start and end are unchanged.getPreviousalready detects it (book.intro).Tradeoffs
#168 (YPE-1343) added the skip with tests but no stated reason. If skipping intros going forward was deliberate (for example, to match the Android Bible app), the fix should probably go the other way: make
previousfrom chapter 1 skip the intro too, so both directions match. This PR follows Swift, the reference for reader behavior. Reviewers, please flag it if the skip was intentional.Blast Radius
BibleReader's next-chapter button: from the last chapter of a book, it now opens the next book's intro, for versions that have intros. Hosts callinggetAdjacentChapterdirectly get the intro in that one case. Versions without intros are unaffected.Verification
{ EXO, '1' }instead of{ EXO, 'INTRO' }). After the fix: 18 passed insrc/getAdjacentChapter.test.ts.pnpm exec turbo testfor core, hooks, and ui: 345 (2 skipped), 200, and 536 passed.pnpm build,pnpm lint, andpnpm exec turbo typecheck --forcepass.Test plan
🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge.Summary
Forward navigation now opens the next book’s intro when one exists.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR A[Last chapter] --> B{Next book exists?} B -->|No| C[Return null] B -->|Yes| D{Has intro?} D -->|Yes| E[Open intro] D -->|No| F[Open first numbered chapter] E -->|Next| FReviews (4) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile