Skip to content

Commit

Permalink
Fix for sub-chaps (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdullahM0hamed authored Mar 14, 2024
1 parent 0aa680e commit f87615c
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import nl.siegmann.epublib.domain.Book
import nl.siegmann.epublib.domain.TOCReference
import nl.siegmann.epublib.epub.EpubReader
import org.commonmark.node.Node
import org.jsoup.Jsoup
Expand Down Expand Up @@ -238,6 +239,17 @@ class QuickBook(val data: QuickStreamData) : AbstractBook() {
}

class RegularBook(val data: Book) : AbstractBook() {
init {
var refs = mutableListOf<TOCReference>()
data.tableOfContents.tocReferences.forEach { ref ->
refs.add(ref)
if (ref.children != null) {
refs.addAll(ref.children)
}
}
data.tableOfContents.tocReferences = refs
}

override val canReload = false

override fun size(): Int {
Expand Down Expand Up @@ -1242,4 +1254,4 @@ class ReadActivityViewModel : ViewModel() {
var screenAwake by PreferenceDelegateLiveView(
EPUB_KEEP_SCREEN_ACTIVE, true, Boolean::class, screenAwakeLive
)
}
}

0 comments on commit f87615c

Please sign in to comment.