This commit is contained in:
Horis 2024-03-26 21:44:59 +08:00
parent e5adb67083
commit 9242dfe476
3 changed files with 13 additions and 5 deletions

View File

@ -283,8 +283,9 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_
} }
upGroupMenuName() upGroupMenuName()
lifecycleScope.launch(IO) { lifecycleScope.launch(IO) {
viewModel.stopSearch()
if (viewModel.refresh()) { if (viewModel.refresh()) {
viewModel.startOrStopSearch() viewModel.startSearch()
} }
} }
} }

View File

@ -167,8 +167,10 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a
fun startSearch() { fun startSearch() {
execute { execute {
stopSearch() stopSearch()
appDb.searchBookDao.clear(name, author) if (searchBooks.isNotEmpty()) {
searchBooks.clear() appDb.searchBookDao.delete(*searchBooks.toTypedArray())
searchBooks.clear()
}
searchCallback?.upAdapter() searchCallback?.upAdapter()
bookSourceParts.clear() bookSourceParts.clear()
val searchGroup = AppConfig.searchGroup val searchGroup = AppConfig.searchGroup

View File

@ -45,6 +45,7 @@ import io.legado.app.utils.startActivity
import io.legado.app.utils.toastOnUi import io.legado.app.utils.toastOnUi
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
import io.legado.app.utils.visible import io.legado.app.utils.visible
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.conflate import kotlinx.coroutines.flow.conflate
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -282,8 +283,12 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
} else { } else {
AppConfig.searchGroup = item.title.toString() AppConfig.searchGroup = item.title.toString()
} }
viewModel.startOrStopSearch() lifecycleScope.launch(IO) {
viewModel.refresh() viewModel.stopSearch()
if (viewModel.refresh()) {
viewModel.startSearch()
}
}
} }
} }
return false return false