Horis 1 vuosi sitten
vanhempi
commit
4488c16ecd

+ 8 - 5
app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceViewModel.kt

@@ -318,12 +318,15 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a
         chapters: List<BookChapter>
     ) = coroutineScope {
         val chapterIndex = if (fromReadBookActivity) {
-            oldBook?.let {
-                BookHelp.getDurChapter(it, chapters)
-            } ?: chapters.lastIndex
-        } else chapters.lastIndex
+            BookHelp.getDurChapter(oldBook!!, chapters)
+        } else {
+            chapters.lastIndex
+        }
         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 pair = try {
             val nextChapterUrl = chapters.getOrNull(chapterIndex + 1)?.url

+ 7 - 2
app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt

@@ -12,6 +12,7 @@ import io.legado.app.help.config.SourceConfig
 import io.legado.app.help.http.CookieStore
 import io.legado.app.help.http.newCallStrResponse
 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.storage.ImportOldData
 import io.legado.app.model.SharedJsScope
@@ -63,8 +64,12 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat
                 }
             }
             bookSource?.let {
-                appDb.bookSourceDao.delete(it)
-                SourceConfig.removeSource(it.bookSourceUrl)
+                if (it.bookSourceUrl != source.bookSourceUrl) {
+                    SourceHelp.deleteBookSource(it.bookSourceUrl)
+                } else {
+                    appDb.bookSourceDao.delete(it)
+                    SourceConfig.removeSource(it.bookSourceUrl)
+                }
             }
             appDb.bookSourceDao.insert(source)
             bookSource = source

+ 3 - 0
app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditViewModel.kt

@@ -7,6 +7,7 @@ import io.legado.app.base.BaseViewModel
 import io.legado.app.data.appDb
 import io.legado.app.data.entities.RssSource
 import io.legado.app.exception.NoStackTraceException
+import io.legado.app.help.AppCacheManager
 import io.legado.app.help.RuleComplete
 import io.legado.app.help.http.CookieStore
 import io.legado.app.utils.GSON
@@ -46,6 +47,8 @@ class RssSourceEditViewModel(application: Application) : BaseViewModel(applicati
                 if (it.sourceUrl != source.sourceUrl) {
                     appDb.rssStarDao.updateOrigin(source.sourceUrl, it.sourceUrl)
                     appDb.rssArticleDao.updateOrigin(source.sourceUrl, it.sourceUrl)
+                    appDb.cacheDao.deleteSourceVariables(it.sourceUrl)
+                    AppCacheManager.clearSourceVariables()
                 }
             }
             appDb.rssSourceDao.insert(source)