Hide the home navigation bar if the user is not a member of any Space.

https://github.com/element-hq/element-meta/issues/2906: `The tab bar with the option to view joined spaces is only shown when the user has at least one space that they have joined (because otherwise they have no clue what to do in here).`
This commit is contained in:
Benoit Marty 2025-09-08 15:17:51 +02:00
parent 943bbee131
commit 0aa33a3cdc
5 changed files with 46 additions and 5 deletions

View file

@ -74,6 +74,12 @@ class HomePresenter(
}
}
LaunchedEffect(homeSpacesState.spaceRooms.isEmpty()) {
// If the last space is left, ensure that the Chat view is rendered.
if (homeSpacesState.spaceRooms.isEmpty()) {
currentHomeNavigationBarItemOrdinal = HomeNavigationBarItem.Chats.ordinal
}
}
val snackbarMessage by snackbarDispatcher.collectSnackbarMessageAsState()
return HomeState(
matrixUser = matrixUser.value,

View file

@ -29,4 +29,5 @@ data class HomeState(
val eventSink: (HomeEvents) -> Unit,
) {
val displayActions = currentHomeNavigationBarItem == HomeNavigationBarItem.Chats
val showNavigationBar = isSpaceFeatureEnabled && homeSpacesState.spaceRooms.isNotEmpty()
}

View file

@ -36,6 +36,8 @@ open class HomeStateProvider : PreviewParameterProvider<HomeState> {
summaries = generateRoomListRoomSummaryList(),
)
),
// For the bottom nav bar to be visible in the preview, the user must be member of at least one space
homeSpacesState = aHomeSpacesState(),
),
aHomeState(
isSpaceFeatureEnabled = true,

View file

@ -194,7 +194,7 @@ private fun HomeScaffold(
)
},
bottomBar = {
if (state.isSpaceFeatureEnabled) {
if (state.showNavigationBar) {
NavigationBar(
containerColor = Color.Transparent,
modifier = Modifier