Skip to content

Commit

Permalink
Update the screen with the new search results when not searching before
Browse files Browse the repository at this point in the history
  • Loading branch information
cristan committed Sep 10, 2024
1 parent ef1a643 commit c995881
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ class HomeViewModel(
val filteredLocations = allLocations.filter { it.title.contains(searchTerm, ignoreCase = true) }
val currentContent = _content.value
if (currentContent is HomeContent.SearchTermContent) {
// Update the search results right away, but load the nearby locations in another thread to avoid flicker
// Update the search results right away, but keep the nearby locations and update them in another thread to avoid flicker
_content.value = currentContent.copy(locations = filteredLocations)
} else {
_content.value = HomeContent.SearchTermContent(filteredLocations, searchTerm, nearbyLocations = null)
}

geoCoderJob?.cancel()
Expand Down

0 comments on commit c995881

Please sign in to comment.