Books — fix infinite render loop via value-based navigation
Opening a book chapter froze the app in an infinite render loop. Root
cause: the books screens used the eager `NavigationLink { destination }`
form inside `List`/`LazyVStack`. That form keeps the destination view
structurally parented to the source row, so `BookReaderView`'s ScrollView
got trapped inside a `List` row — a row sizes to intrinsic height, a
ScrollView has none, so the two never converge and re-measure forever.
Switch the whole books navigation chain to value-based navigation:
- practiceHomeView, BookLibraryView, BookChapterListView use
NavigationLink(value:).
- PracticeView's NavigationStack declares the BooksRoute, Book, and
BookChapter destinations once, at the stack root (mixing eager and
value-based pushes in one path caused pushed screens to pop back).
- BookReaderView is built from just a BookChapter; it resolves its Book
by slug via @Query.
Also:
- BookChapter gains a stored paragraphCount so the chapter list no longer
decodes the full paragraph JSON on every render (bookDataVersion -> 6
to re-seed).
- BookSpeechController builds its AVSpeechSynthesizer lazily.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,9 @@ public final class BookChapter {
|
||||
public var bookSlug: String = ""
|
||||
public var number: Int = 0
|
||||
public var title: String = ""
|
||||
/// Spanish paragraph count, stored at seed time so chapter lists can show
|
||||
/// it without decoding the full `paragraphsESJSON` blob on every render.
|
||||
public var paragraphCount: Int = 0
|
||||
public var paragraphsESJSON: Data = Data()
|
||||
public var paragraphsENJSON: Data = Data()
|
||||
|
||||
@@ -18,6 +21,7 @@ public final class BookChapter {
|
||||
bookSlug: String,
|
||||
number: Int,
|
||||
title: String,
|
||||
paragraphCount: Int,
|
||||
paragraphsESJSON: Data,
|
||||
paragraphsENJSON: Data
|
||||
) {
|
||||
@@ -25,6 +29,7 @@ public final class BookChapter {
|
||||
self.bookSlug = bookSlug
|
||||
self.number = number
|
||||
self.title = title
|
||||
self.paragraphCount = paragraphCount
|
||||
self.paragraphsESJSON = paragraphsESJSON
|
||||
self.paragraphsENJSON = paragraphsENJSON
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user