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()
lifecycleScope.launch(IO) {
viewModel.stopSearch()
if (viewModel.refresh()) {
viewModel.startOrStopSearch()
viewModel.startSearch()
}
}
}

View File

@ -167,8 +167,10 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a
fun startSearch() {
execute {
stopSearch()
appDb.searchBookDao.clear(name, author)
searchBooks.clear()
if (searchBooks.isNotEmpty()) {
appDb.searchBookDao.delete(*searchBooks.toTypedArray())
searchBooks.clear()
}
searchCallback?.upAdapter()
bookSourceParts.clear()
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.viewbindingdelegate.viewBinding
import io.legado.app.utils.visible
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.conflate
import kotlinx.coroutines.launch
@ -282,8 +283,12 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
} else {
AppConfig.searchGroup = item.title.toString()
}
viewModel.startOrStopSearch()
viewModel.refresh()
lifecycleScope.launch(IO) {
viewModel.stopSearch()
if (viewModel.refresh()) {
viewModel.startSearch()
}
}
}
}
return false