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) {
|
||||
val allQueries = searchHistoryRepository.getAll()
|
||||
allQueries.filterNot {
|
||||
it.query == query
|
||||
}.run {
|
||||
this.forEach {
|
||||
searchHistoryRepository.insert(it.query)
|
||||
}
|
||||
if (allQueries.none { it.query == query }){
|
||||
searchHistoryRepository.insert(query)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun deleteAllSearchQueryHistory() = viewModelScope.launch(Dispatchers.IO){
|
||||
|
|
|
|||
Loading…
Reference in a new issue