This commit is contained in:
Horis
2025-05-19 13:38:37 +08:00
parent 77cd1378da
commit 4488c16ecd
3 changed files with 18 additions and 7 deletions
@@ -318,12 +318,15 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a
chapters: List<BookChapter> chapters: List<BookChapter>
) = coroutineScope { ) = coroutineScope {
val chapterIndex = if (fromReadBookActivity) { val chapterIndex = if (fromReadBookActivity) {
oldBook?.let { BookHelp.getDurChapter(oldBook!!, chapters)
BookHelp.getDurChapter(it, chapters) } else {
} ?: chapters.lastIndex chapters.lastIndex
} else chapters.lastIndex }
val bookChapter = chapters[chapterIndex] val bookChapter = chapters[chapterIndex]
val title = bookChapter.title.trim() var title = bookChapter.title.trim()
if (title.length > 20) {
title = title.substring(0, 20) + ""
}
val startTime = System.currentTimeMillis() val startTime = System.currentTimeMillis()
val pair = try { val pair = try {
val nextChapterUrl = chapters.getOrNull(chapterIndex + 1)?.url val nextChapterUrl = chapters.getOrNull(chapterIndex + 1)?.url
@@ -12,6 +12,7 @@ import io.legado.app.help.config.SourceConfig
import io.legado.app.help.http.CookieStore import io.legado.app.help.http.CookieStore
import io.legado.app.help.http.newCallStrResponse import io.legado.app.help.http.newCallStrResponse
import io.legado.app.help.http.okHttpClient import io.legado.app.help.http.okHttpClient
import io.legado.app.help.source.SourceHelp
import io.legado.app.help.source.clearExploreKindsCache import io.legado.app.help.source.clearExploreKindsCache
import io.legado.app.help.storage.ImportOldData import io.legado.app.help.storage.ImportOldData
import io.legado.app.model.SharedJsScope import io.legado.app.model.SharedJsScope
@@ -63,9 +64,13 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat
} }
} }
bookSource?.let { bookSource?.let {
if (it.bookSourceUrl != source.bookSourceUrl) {
SourceHelp.deleteBookSource(it.bookSourceUrl)
} else {
appDb.bookSourceDao.delete(it) appDb.bookSourceDao.delete(it)
SourceConfig.removeSource(it.bookSourceUrl) SourceConfig.removeSource(it.bookSourceUrl)
} }
}
appDb.bookSourceDao.insert(source) appDb.bookSourceDao.insert(source)
bookSource = source bookSource = source
source source
@@ -7,6 +7,7 @@ import io.legado.app.base.BaseViewModel
import io.legado.app.data.appDb import io.legado.app.data.appDb
import io.legado.app.data.entities.RssSource import io.legado.app.data.entities.RssSource
import io.legado.app.exception.NoStackTraceException import io.legado.app.exception.NoStackTraceException
import io.legado.app.help.AppCacheManager
import io.legado.app.help.RuleComplete import io.legado.app.help.RuleComplete
import io.legado.app.help.http.CookieStore import io.legado.app.help.http.CookieStore
import io.legado.app.utils.GSON import io.legado.app.utils.GSON
@@ -46,6 +47,8 @@ class RssSourceEditViewModel(application: Application) : BaseViewModel(applicati
if (it.sourceUrl != source.sourceUrl) { if (it.sourceUrl != source.sourceUrl) {
appDb.rssStarDao.updateOrigin(source.sourceUrl, it.sourceUrl) appDb.rssStarDao.updateOrigin(source.sourceUrl, it.sourceUrl)
appDb.rssArticleDao.updateOrigin(source.sourceUrl, it.sourceUrl) appDb.rssArticleDao.updateOrigin(source.sourceUrl, it.sourceUrl)
appDb.cacheDao.deleteSourceVariables(it.sourceUrl)
AppCacheManager.clearSourceVariables()
} }
} }
appDb.rssSourceDao.insert(source) appDb.rssSourceDao.insert(source)