Fixed unit list loading

This commit is contained in:
Sad Ellie 2022-06-12 12:36:10 +03:00
parent 72f6d2e4f7
commit bc55e23e04
2 changed files with 3 additions and 7 deletions

View File

@ -421,6 +421,9 @@ class MainViewModel @Inject constructor(
leftSide: Boolean
) {
viewModelScope.launch {
// Prevent user from seeing invalid list
unitsToShow = emptyMap()
val filterGroup: Boolean = chosenUnitGroup != null
// This is mostly not UI related stuff and viewModelScope.launch uses Dispatchers.Main

View File

@ -105,13 +105,6 @@ fun SecondScreen(
LaunchedEffect(Unit) {
/**
* Telling viewModel that it needs to update the list
* Also while the below is being computed user will composable will use cached list from viewModel
*
* User actually doesn't see cached list. Computation takes few milliseconds since we don't
* compute any Levenshtein distance when the screen is launched and the list is limited
* to a specific [UnitGroup]
*
* Adding animation/spinners will cause flickering and confuse user
*/
viewModel.loadUnitsToShow(searchQuery, chosenUnitGroup, leftSide)
// Scrolling chips to current group