fixed search history duplicates
This commit is contained in:
parent
7d5f32b4bf
commit
de051889ee
1 changed files with 3 additions and 6 deletions
|
|
@ -106,13 +106,10 @@ class ResultViewModel(application: Application) : AndroidViewModel(application)
|
||||||
|
|
||||||
fun addSearchQueryToHistory(query: String) = viewModelScope.launch(Dispatchers.IO) {
|
fun addSearchQueryToHistory(query: String) = viewModelScope.launch(Dispatchers.IO) {
|
||||||
val allQueries = searchHistoryRepository.getAll()
|
val allQueries = searchHistoryRepository.getAll()
|
||||||
allQueries.filterNot {
|
if (allQueries.none { it.query == query }){
|
||||||
it.query == query
|
searchHistoryRepository.insert(query)
|
||||||
}.run {
|
|
||||||
this.forEach {
|
|
||||||
searchHistoryRepository.insert(it.query)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deleteAllSearchQueryHistory() = viewModelScope.launch(Dispatchers.IO){
|
fun deleteAllSearchQueryHistory() = viewModelScope.launch(Dispatchers.IO){
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue