Do not display the FloatingBottomBar on empty actions

ET-6283
This commit is contained in:
Niccolò Forlini
2026-05-26 09:50:56 +00:00
parent 1d4d41bcbc
commit 25439a541c
2 changed files with 12 additions and 4 deletions
@@ -28,10 +28,11 @@ class BottomBarReducer @Inject constructor() {
fun newStateFrom(currentState: BottomBarState, event: BottomBarEvent): BottomBarState {
return when (event) {
is BottomBarEvent.ActionsData -> currentState.toNewStateForActionData(event)
is BottomBarEvent.ShowAndUpdateActionsData -> BottomBarState.Data.Shown(
event.target,
event.actionUiModels
)
is BottomBarEvent.ShowAndUpdateActionsData -> if (event.actionUiModels.isEmpty()) {
BottomBarState.Data.Hidden(event.target, event.actionUiModels)
} else {
BottomBarState.Data.Shown(event.target, event.actionUiModels)
}
is BottomBarEvent.HideBottomSheet -> currentState.toNewStateForHiding()
is BottomBarEvent.ShowBottomSheet -> currentState.toNewStateForShowing()
@@ -19,6 +19,7 @@
package ch.protonmail.android.mailcommon.presentation.reducer
import arrow.core.nonEmptyListOf
import ch.protonmail.android.mailcommon.presentation.model.ActionUiModel
import ch.protonmail.android.mailcommon.presentation.model.BottomBarEvent
import ch.protonmail.android.mailcommon.presentation.model.BottomBarState
import ch.protonmail.android.mailcommon.presentation.model.BottomBarTarget
@@ -48,6 +49,7 @@ internal class BottomBarReducerTest(
private val actions = nonEmptyListOf(ActionUiModelTestData.markUnread).toImmutableList()
private val updatedActions = listOf(ActionUiModelTestData.archive).toImmutableList()
private val emptyActions = emptyList<ActionUiModel>().toImmutableList()
private val mailboxTarget = BottomBarTarget.Mailbox
private val convoTarget = BottomBarTarget.Conversation
private val messageTarget = BottomBarTarget.Message(id = "messageId")
@@ -73,6 +75,11 @@ internal class BottomBarReducerTest(
currentState = BottomBarState.Loading,
operation = BottomBarEvent.Offline,
expectedState = BottomBarState.Offline
),
TestInput(
currentState = BottomBarState.Loading,
operation = BottomBarEvent.ShowAndUpdateActionsData(convoTarget, emptyActions),
expectedState = BottomBarState.Data.Hidden(convoTarget, emptyActions)
)
)