diff --git a/app/src/main/java/io/legado/app/ui/search/SearchViewModel.kt b/app/src/main/java/io/legado/app/ui/search/SearchViewModel.kt index e8276db87..33381933b 100644 --- a/app/src/main/java/io/legado/app/ui/search/SearchViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/search/SearchViewModel.kt @@ -35,11 +35,13 @@ class SearchViewModel(application: Application) : BaseViewModel(application) { .timeout(30000L) .onSuccess(Dispatchers.IO) { it?.let { list -> - App.db.searchBookDao().insert(*list.toTypedArray()) + list.map { searchBook -> + if (searchBook.name.contains(key) || searchBook.author.contains(key)) + App.db.searchBookDao().insert(searchBook) + } } } } - }.onError { it.printStackTrace() }