From 03d1aa0f8ee4020847dafa1a6a226a4cf62b86a8 Mon Sep 17 00:00:00 2001 From: Mustafa Ozhan Date: Sun, 15 Sep 2024 11:35:55 +0200 Subject: [PATCH] [Oztechan/CCC#3933] Move loadings into beginning of observations (#3934) --- .../ccc/client/viewmodel/calculator/CalculatorViewModel.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/viewmodel/calculator/src/commonMain/kotlin/com/oztechan/ccc/client/viewmodel/calculator/CalculatorViewModel.kt b/client/viewmodel/calculator/src/commonMain/kotlin/com/oztechan/ccc/client/viewmodel/calculator/CalculatorViewModel.kt index 6d735d9e5..060e5683d 100644 --- a/client/viewmodel/calculator/src/commonMain/kotlin/com/oztechan/ccc/client/viewmodel/calculator/CalculatorViewModel.kt +++ b/client/viewmodel/calculator/src/commonMain/kotlin/com/oztechan/ccc/client/viewmodel/calculator/CalculatorViewModel.kt @@ -81,6 +81,7 @@ class CalculatorViewModel( private fun observeBase() = state.map { it.base } .distinctUntilChanged() .onEach { + setState { copy(loading = true) } Logger.d { "CalculatorViewModel observeBase $it" } calculationStorage.currentBase = it currentBaseChanged(it) @@ -91,6 +92,7 @@ class CalculatorViewModel( private fun observeInput() = state.map { it.input } .distinctUntilChanged() .onEach { + setState { copy(loading = true) } Logger.d { "CalculatorViewModel observeInput $it" } calculationStorage.lastInput = it calculateOutput(it) @@ -98,8 +100,6 @@ class CalculatorViewModel( .launchIn(viewModelScope) private fun updateConversion() { - setState { copy(loading = true) } - data.conversion?.let { calculateConversions(it, ConversionState.Cached(it.date)) } ?: viewModelScope.launch {