Check and Filter blank and empty error messages

pull/1461/head
TM 1 year ago
parent ee5c29f805
commit 2bf6689108

@ -121,13 +121,13 @@ class NiaAppState(
) )
private val errorMessages = MutableStateFlow<List<ErrorMessage>>(emptyList()) private val errorMessages = MutableStateFlow<List<ErrorMessage>>(emptyList())
val errorMessage: StateFlow<String?> = errorMessages.map { it.firstOrNull()?.message }.stateIn( val errorMessage: StateFlow<String?> = errorMessages.map { it.filter { it.message.isNotEmpty() && it.message.isNotBlank() }.firstOrNull()?.message }.stateIn(
scope = coroutineScope, scope = coroutineScope,
started = SharingStarted.WhileSubscribed(5_000), started = SharingStarted.WhileSubscribed(5_000),
initialValue = null, initialValue = null,
) )
fun addErrorMessage(error: String) { fun addErrorMessage(error: String) {
errorMessages.update { it + ErrorMessage(error) } if(error.isNotEmpty() && error.isNotBlank()) errorMessages.update { it + ErrorMessage(error) }
} }
fun clearErrorMessage() { fun clearErrorMessage() {

Loading…
Cancel
Save