From f87615c87c5dd129e3799388c01b540b1eb77e91 Mon Sep 17 00:00:00 2001 From: Red <25087116+AbdullahM0hamed@users.noreply.github.com> Date: Thu, 14 Mar 2024 18:45:08 +0000 Subject: [PATCH] Fix for sub-chaps (#227) --- .../lagradost/quicknovel/ReadActivityViewModel.kt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/lagradost/quicknovel/ReadActivityViewModel.kt b/app/src/main/java/com/lagradost/quicknovel/ReadActivityViewModel.kt index 558fc7e9..94d776a9 100644 --- a/app/src/main/java/com/lagradost/quicknovel/ReadActivityViewModel.kt +++ b/app/src/main/java/com/lagradost/quicknovel/ReadActivityViewModel.kt @@ -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 @@ -238,6 +239,17 @@ class QuickBook(val data: QuickStreamData) : AbstractBook() { } class RegularBook(val data: Book) : AbstractBook() { + init { + var refs = mutableListOf() + 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 { @@ -1242,4 +1254,4 @@ class ReadActivityViewModel : ViewModel() { var screenAwake by PreferenceDelegateLiveView( EPUB_KEEP_SCREEN_ACTIVE, true, Boolean::class, screenAwakeLive ) -} \ No newline at end of file +}