From c9958816569eadbd11847ec72797f619e567fe7a Mon Sep 17 00:00:00 2001 From: Cristan Meijer Date: Tue, 10 Sep 2024 15:45:58 +0200 Subject: [PATCH] Update the screen with the new search results when not searching before --- .../java/nl/ovfietsbeschikbaarheid/viewmodel/HomeViewModel.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/nl/ovfietsbeschikbaarheid/viewmodel/HomeViewModel.kt b/app/src/main/java/nl/ovfietsbeschikbaarheid/viewmodel/HomeViewModel.kt index fccf249..490e209 100644 --- a/app/src/main/java/nl/ovfietsbeschikbaarheid/viewmodel/HomeViewModel.kt +++ b/app/src/main/java/nl/ovfietsbeschikbaarheid/viewmodel/HomeViewModel.kt @@ -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()