diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/StateHandler.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/StateHandler.kt index 4572b49..da02286 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/StateHandler.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/StateHandler.kt @@ -1,8 +1,6 @@ package net.codinux.banking.ui.composables -import androidx.compose.runtime.Composable -import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.getValue +import androidx.compose.runtime.* import net.codinux.banking.ui.dialogs.ApplicationErrorDialog import net.codinux.banking.ui.dialogs.BankingClientErrorDialog import net.codinux.banking.ui.dialogs.EnterTanDialog @@ -10,13 +8,13 @@ import net.codinux.banking.ui.state.UiState @Composable fun StateHandler(uiState: UiState) { - val applicationError by uiState.applicationErrorOccurred.collectAsState() - val bankingClientError by uiState.bankingClientErrorOccurred.collectAsState() val tanChallengeReceived by uiState.tanChallengeReceived.collectAsState() + val bankingClientError by uiState.bankingClientErrorOccurred.collectAsState() + val applicationError by uiState.applicationErrorOccurred.collectAsState() - applicationError?.let { error -> - ApplicationErrorDialog(error) { - uiState.applicationErrorOccurred.value = null + tanChallengeReceived?.let { tanChallengeReceived -> + EnterTanDialog(tanChallengeReceived) { + uiState.tanChallengeReceived.value = null } } @@ -26,9 +24,9 @@ fun StateHandler(uiState: UiState) { } } - tanChallengeReceived?.let { tanChallengeReceived -> - EnterTanDialog(tanChallengeReceived) { - uiState.tanChallengeReceived.value = null + applicationError?.let { error -> + ApplicationErrorDialog(error) { + uiState.applicationErrorOccurred.value = null } } diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/state/UiState.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/state/UiState.kt index dd8d90f..a6b469e 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/state/UiState.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/state/UiState.kt @@ -25,11 +25,11 @@ class UiState : ViewModel() { val accountFilter = MutableStateFlow>(emptyList()) - val applicationErrorOccurred = MutableStateFlow(null) + val tanChallengeReceived = MutableStateFlow(null) val bankingClientErrorOccurred = MutableStateFlow(null) - val tanChallengeReceived = MutableStateFlow(null) + val applicationErrorOccurred = MutableStateFlow(null) fun applicationErrorOccurred(erroneousAction: ErroneousAction, exception: Throwable, errorMessage: String? = null) {