This commit is contained in:
Horis 2024-12-08 21:37:22 +08:00
parent 2737254fec
commit 1c2eb8ef7d

View File

@ -113,9 +113,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
return return
} }
ReadBook.upMsg(null) ReadBook.upMsg(null)
if (ReadBook.simulatedChapterSize > 0 && ReadBook.durChapterIndex > ReadBook.simulatedChapterSize - 1) { ensureChapterExist()
ReadBook.durChapterIndex = ReadBook.simulatedChapterSize - 1
}
if (!isSameBook) { if (!isSameBook) {
ReadBook.loadContent(resetPageOffset = true) ReadBook.loadContent(resetPageOffset = true)
} else { } else {
@ -150,6 +148,12 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
} }
} }
private fun ensureChapterExist() {
if (ReadBook.simulatedChapterSize > 0 && ReadBook.durChapterIndex > ReadBook.simulatedChapterSize - 1) {
ReadBook.durChapterIndex = ReadBook.simulatedChapterSize - 1
}
}
/** /**
* 加载详情页 * 加载详情页
*/ */
@ -170,6 +174,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
fun loadChapterList(book: Book) { fun loadChapterList(book: Book) {
execute { execute {
if (loadChapterListAwait(book)) { if (loadChapterListAwait(book)) {
ensureChapterExist()
ReadBook.upMsg(null) ReadBook.upMsg(null)
ReadBook.loadContent(resetPageOffset = true) ReadBook.loadContent(resetPageOffset = true)
} }