Skip to content

Commit

Permalink
Refactor state holder and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrucaraus committed Aug 7, 2024
1 parent f78559d commit f9a6cf8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ fun ArticleFilterActionIcon(
) {
IconButton(
modifier = modifier,
onClick = filterState.show
onClick = filterState.show,
) {
Box {
if (filterState.isSet) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ fun AudioCommandButton(
FloatingActionButton(
modifier = modifier,
onClick = {
if (hasPermission(context)) {
state.toggleListening()
} else {
requestPermission = true
}
}) {
if (hasPermission(context)) {
state.toggleListening()
} else {
requestPermission = true
}
},
) {
if (state.isListening) {
val scaleDB = state.audioInputChangesDb.coerceIn(
minimumValue = 1f,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,21 @@ class ArticlesListStateHolder(
private fun updateSuccess(articles: List<Article>) {
listUiState.update {
it.copy(
list = articles, isLoading = false, isError = false, errorMessage = null,
list = articles,
isLoading = false,
isError = false,
errorMessage = null,
)
}
}

private fun updateError(error: Error) {
listUiState.update {
it.copy(
list = emptyList(), isLoading = false, isError = true, errorMessage = error.message,
list = emptyList(),
isLoading = false,
isError = true,
errorMessage = error.message,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,4 @@ class SpeechRecognizerStateHolder(
private fun resetToast() {
toasterState.update { it.copy(showToast = false, message = "") }
}

}

0 comments on commit f9a6cf8

Please sign in to comment.