Skip to content

refactor: Add Chapter types, lift spine-range to Epub#56

Merged
znelson merged 1 commit into
mainfrom
chapter-refactor
May 24, 2026
Merged

refactor: Add Chapter types, lift spine-range to Epub#56
znelson merged 1 commit into
mainfrom
chapter-refactor

Conversation

@znelson
Copy link
Copy Markdown
Owner

@znelson znelson commented May 24, 2026

Introduce lib/Epub/Epub/Chapter.h with Chapter, ChapterTarget, and SpineRange POD types in preparation for unifying the scattered chapter representations across Section, EpubReaderActivity, and ActivityResult. Move the spine-range-for-TOC-index computation from EpubReaderActivity::prepareSection into Epub::getSpineRangeForTocIndex where it belongs. Rename ChapterResult to ChapterTarget for consistency with the new type taxonomy. Pure-rename + additive; no behavior change.

@znelson znelson enabled auto-merge (squash) May 24, 2026 15:38
@znelson znelson merged commit 04ea00b into main May 24, 2026
7 checks passed
@znelson znelson deleted the chapter-refactor branch May 24, 2026 15:41
znelson added a commit that referenced this pull request May 24, 2026
Replace TocBoundary (Section) and SpineSegment (EpubReaderActivity) with
the unified Chapter type from phase 1 (PR #56). Delete TocPageRange;
getPageRangeForTocIndex now returns std::optional directly.

Drop the denormalized cumulativeOffset and totalPages fields.
getChapterRelativePage is rewritten as a running sum over
chapterPageInfo.segments (N <= 3 in practice). New
getChapterTotalPages() helper exposes the chapter total to status bar
and reader menu without storing it on the side.

Section::tocBoundaries now precomputes endPage at build time (post-sort)
instead of recomputing it in each getPageRangeForTocIndex call.

No behavior change. RAM unchanged; flash drops ~1.3 KB. On-disk section
cache format unchanged (no SECTION_FILE_VERSION bump).
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.

1 participant