优化同时校验搜索和发现的提示逻辑

纯发现源(搜索链接为空) 跳过校验搜索
搜索链接不为空 搜索失效时最终校验提示失败
pull/1568/head
Xwite 3 years ago
parent 27bc4787e3
commit 515120c3a3
  1. 7
      app/src/main/java/io/legado/app/data/entities/BookSource.kt
  2. 8
      app/src/main/java/io/legado/app/service/CheckSourceService.kt

@ -134,6 +134,13 @@ data class BookSource(
return this
}
fun hasGroup(group: String): Boolean {
bookSourceGroup?.splitNotBlank(AppPattern.splitGroupRegex)?.toHashSet()?.let {
return if (it.indexOf(group) != -1) true else false
}
return false
}
fun equal(source: BookSource) =
equal(bookSourceName, source.bookSourceName)
&& equal(bookSourceUrl, source.bookSourceUrl)

@ -121,8 +121,8 @@ class CheckSourceService : BaseService() {
searchWord = it
}
}
//校验搜索
if (CheckSource.checkSearch) {
//校验搜索 用户设置校验搜索 并且 搜索链接不为空
if (CheckSource.checkSearch && !source.searchUrl.isNullOrBlank()) {
books = WebBook.searchBookAwait(this, source, searchWord)
if (books.isEmpty()) source.addGroup("搜索失效") else source.removeGroup("搜索失效")
}
@ -187,7 +187,11 @@ class CheckSourceService : BaseService() {
?.filterNot {
it.startsWith("Error: ")
}?.joinToString("\n")
if (source.hasGroup("搜索失效")) {
Debug.updateFinalMessage(source.bookSourceUrl, "失败")
} else {
Debug.updateFinalMessage(source.bookSourceUrl, "成功")
}
}.onFinally(searchCoroutine) {
source.respondTime = Debug.getRespondTime(source.bookSourceUrl)
appDb.bookSourceDao.update(source)

Loading…
Cancel
Save