Remove FF CreateSpaces
This commit is contained in:
parent
b6ce6a95c0
commit
64b0a7eef3
11 changed files with 33 additions and 119 deletions
|
|
@ -94,12 +94,6 @@ class HomePresenter(
|
|||
}
|
||||
}
|
||||
|
||||
LaunchedEffect(homeSpacesState.canCreateSpaces, homeSpacesState.spaceRooms.isEmpty()) {
|
||||
// If the flag to create spaces is disabled and the last space is left, ensure that the Chat view is rendered.
|
||||
if (!homeSpacesState.canCreateSpaces && homeSpacesState.spaceRooms.isEmpty()) {
|
||||
currentHomeNavigationBarItemOrdinal = HomeNavigationBarItem.Chats.ordinal
|
||||
}
|
||||
}
|
||||
val snackbarMessage by snackbarDispatcher.collectSnackbarMessageAsState()
|
||||
return HomeState(
|
||||
currentUserAndNeighbors = currentUserAndNeighbors,
|
||||
|
|
|
|||
|
|
@ -34,5 +34,4 @@ data class HomeState(
|
|||
) {
|
||||
val isBackHandlerEnabled = currentHomeNavigationBarItem != HomeNavigationBarItem.Chats || roomListState.spaceFiltersState is SpaceFiltersState.Selected
|
||||
val displayRoomListFilters = currentHomeNavigationBarItem == HomeNavigationBarItem.Chats && roomListState.displayFilters
|
||||
val showNavigationBar = homeSpacesState.canCreateSpaces || homeSpacesState.spaceRooms.isNotEmpty()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -199,50 +199,41 @@ private fun HomeScaffold(
|
|||
)
|
||||
},
|
||||
floatingActionButton = {
|
||||
if (state.showNavigationBar) {
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
HomeBottomBar(
|
||||
currentHomeNavigationBarItem = state.currentHomeNavigationBarItem,
|
||||
onItemClick = { item ->
|
||||
// scroll to top if selecting the same item
|
||||
if (item == state.currentHomeNavigationBarItem) {
|
||||
val lazyListStateTarget = when (item) {
|
||||
HomeNavigationBarItem.Chats -> roomsLazyListState
|
||||
HomeNavigationBarItem.Spaces -> spacesLazyListState
|
||||
}
|
||||
coroutineScope.launch {
|
||||
if (lazyListStateTarget.firstVisibleItemIndex > 10) {
|
||||
lazyListStateTarget.scrollToItem(10)
|
||||
}
|
||||
// Also reset the scrollBehavior height offset as it's not triggered by programmatic scrolls
|
||||
scrollBehavior.state.heightOffset = 0f
|
||||
lazyListStateTarget.animateScrollToItem(0)
|
||||
}
|
||||
} else {
|
||||
state.eventSink(HomeEvent.SelectHomeNavigationBarItem(item))
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
HomeBottomBar(
|
||||
currentHomeNavigationBarItem = state.currentHomeNavigationBarItem,
|
||||
onItemClick = { item ->
|
||||
// scroll to top if selecting the same item
|
||||
if (item == state.currentHomeNavigationBarItem) {
|
||||
val lazyListStateTarget = when (item) {
|
||||
HomeNavigationBarItem.Chats -> roomsLazyListState
|
||||
HomeNavigationBarItem.Spaces -> spacesLazyListState
|
||||
}
|
||||
},
|
||||
floatingActionButton = when (state.currentHomeNavigationBarItem) {
|
||||
coroutineScope.launch {
|
||||
if (lazyListStateTarget.firstVisibleItemIndex > 10) {
|
||||
lazyListStateTarget.scrollToItem(10)
|
||||
}
|
||||
// Also reset the scrollBehavior height offset as it's not triggered by programmatic scrolls
|
||||
scrollBehavior.state.heightOffset = 0f
|
||||
lazyListStateTarget.animateScrollToItem(0)
|
||||
}
|
||||
} else {
|
||||
state.eventSink(HomeEvent.SelectHomeNavigationBarItem(item))
|
||||
}
|
||||
},
|
||||
floatingActionButton = {
|
||||
when (state.currentHomeNavigationBarItem) {
|
||||
HomeNavigationBarItem.Chats -> {
|
||||
{
|
||||
HomeFloatingActionButton(onStartChatClick, CommonStrings.action_create_room)
|
||||
}
|
||||
HomeFloatingActionButton(onStartChatClick, CommonStrings.action_create_room)
|
||||
}
|
||||
HomeNavigationBarItem.Spaces -> if (state.homeSpacesState.canCreateSpaces) {
|
||||
{
|
||||
HomeFloatingActionButton(onCreateSpaceClick, CommonStrings.action_create_space)
|
||||
}
|
||||
} else {
|
||||
// No FAB for spaces if we cannot create spaces
|
||||
null
|
||||
HomeNavigationBarItem.Spaces -> {
|
||||
HomeFloatingActionButton(onCreateSpaceClick, CommonStrings.action_create_space)
|
||||
}
|
||||
},
|
||||
)
|
||||
} else {
|
||||
HomeFloatingActionButton(onStartChatClick, CommonStrings.action_create_room)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
},
|
||||
floatingActionButtonPosition = if (state.showNavigationBar) FabPosition.Center else FabPosition.End,
|
||||
floatingActionButtonPosition = FabPosition.Center,
|
||||
content = { padding ->
|
||||
val contentPadding = PaddingValues(
|
||||
bottom = 96.dp,
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@ import androidx.compose.runtime.remember
|
|||
import dev.zacsweers.metro.Inject
|
||||
import io.element.android.features.invite.api.SeenInvitesStore
|
||||
import io.element.android.libraries.architecture.Presenter
|
||||
import io.element.android.libraries.featureflag.api.FeatureFlagService
|
||||
import io.element.android.libraries.featureflag.api.FeatureFlags
|
||||
import io.element.android.libraries.matrix.api.MatrixClient
|
||||
import io.element.android.libraries.matrix.ui.safety.rememberHideInvitesAvatar
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
|
@ -29,11 +27,9 @@ import kotlinx.coroutines.flow.map
|
|||
class HomeSpacesPresenter(
|
||||
private val client: MatrixClient,
|
||||
private val seenInvitesStore: SeenInvitesStore,
|
||||
private val featureFlagsService: FeatureFlagService,
|
||||
) : Presenter<HomeSpacesState> {
|
||||
@Composable
|
||||
override fun present(): HomeSpacesState {
|
||||
val canCreateSpaces by featureFlagsService.isFeatureEnabledFlow(FeatureFlags.CreateSpaces).collectAsState(false)
|
||||
val hideInvitesAvatar by client.rememberHideInvitesAvatar()
|
||||
val spaceRooms by remember {
|
||||
client.spaceService.topLevelSpacesFlow.map { it.toImmutableList() }
|
||||
|
|
@ -52,7 +48,6 @@ class HomeSpacesPresenter(
|
|||
spaceRooms = spaceRooms,
|
||||
seenSpaceInvites = seenSpaceInvites,
|
||||
hideInvitesAvatar = hideInvitesAvatar,
|
||||
canCreateSpaces = canCreateSpaces,
|
||||
// TODO enable once we can link to the screen to explore public spaces
|
||||
canExploreSpaces = false,
|
||||
eventSink = ::handleEvent,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ data class HomeSpacesState(
|
|||
val spaceRooms: ImmutableList<SpaceRoom>,
|
||||
val seenSpaceInvites: ImmutableSet<RoomId>,
|
||||
val hideInvitesAvatar: Boolean,
|
||||
val canCreateSpaces: Boolean,
|
||||
val canExploreSpaces: Boolean,
|
||||
val eventSink: (HomeSpacesEvents) -> Unit,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -30,17 +30,9 @@ open class HomeSpacesStateProvider : PreviewParameterProvider<HomeSpacesState> {
|
|||
),
|
||||
spaceRooms = aListOfSpaceRooms(),
|
||||
),
|
||||
aHomeSpacesState(
|
||||
space = CurrentSpace.Space(
|
||||
spaceRoom = aSpaceRoom(roomId = RoomId("!mySpace:example.com"))
|
||||
),
|
||||
spaceRooms = aListOfSpaceRooms(),
|
||||
canCreateSpaces = false,
|
||||
),
|
||||
aHomeSpacesState(
|
||||
space = CurrentSpace.Root,
|
||||
spaceRooms = emptyList(),
|
||||
canCreateSpaces = true,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
@ -50,7 +42,6 @@ internal fun aHomeSpacesState(
|
|||
spaceRooms: List<SpaceRoom> = aListOfSpaceRooms(),
|
||||
seenSpaceInvites: Set<RoomId> = emptySet(),
|
||||
hideInvitesAvatar: Boolean = false,
|
||||
canCreateSpaces: Boolean = true,
|
||||
canExploreSpaces: Boolean = true,
|
||||
eventSink: (HomeSpacesEvents) -> Unit = {},
|
||||
) = HomeSpacesState(
|
||||
|
|
@ -58,7 +49,6 @@ internal fun aHomeSpacesState(
|
|||
spaceRooms = spaceRooms.toImmutableList(),
|
||||
seenSpaceInvites = seenSpaceInvites.toImmutableSet(),
|
||||
hideInvitesAvatar = hideInvitesAvatar,
|
||||
canCreateSpaces = canCreateSpaces,
|
||||
canExploreSpaces = canExploreSpaces,
|
||||
eventSink = eventSink,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ fun HomeSpacesView(
|
|||
onExploreClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
if (state.canCreateSpaces && state.spaceRooms.isEmpty()) {
|
||||
if (state.spaceRooms.isEmpty()) {
|
||||
EmptySpaceHomeView(
|
||||
modifier = modifier.padding(contentPadding),
|
||||
onCreateSpaceClick = onCreateSpaceClick,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue