space: add space settings ff and branch it
This commit is contained in:
parent
a89484e826
commit
185ef152fe
5 changed files with 20 additions and 2 deletions
|
|
@ -26,6 +26,8 @@ import io.element.android.libraries.architecture.AsyncAction
|
|||
import io.element.android.libraries.architecture.Presenter
|
||||
import io.element.android.libraries.core.coroutine.mapState
|
||||
import io.element.android.libraries.di.annotations.SessionCoroutineScope
|
||||
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.api.core.RoomId
|
||||
import io.element.android.libraries.matrix.api.core.toRoomIdOrAlias
|
||||
|
|
@ -53,6 +55,7 @@ class SpacePresenter(
|
|||
private val joinRoom: JoinRoom,
|
||||
private val acceptDeclineInvitePresenter: Presenter<AcceptDeclineInviteState>,
|
||||
@SessionCoroutineScope private val sessionCoroutineScope: CoroutineScope,
|
||||
private val featureFlagService: FeatureFlagService,
|
||||
) : Presenter<SpaceState> {
|
||||
private var children by mutableStateOf<ImmutableList<SpaceRoom>>(persistentListOf())
|
||||
|
||||
|
|
@ -79,6 +82,10 @@ class SpacePresenter(
|
|||
}
|
||||
}.collectAsState()
|
||||
|
||||
val isSpaceSettingsEnabled by remember {
|
||||
featureFlagService.isFeatureEnabledFlow(FeatureFlags.SpaceSettings)
|
||||
}.collectAsState(false)
|
||||
|
||||
val currentSpace by spaceRoomList.currentSpaceFlow.collectAsState()
|
||||
val (joinActions, setJoinActions) = remember { mutableStateOf(emptyMap<RoomId, AsyncAction<Unit>>()) }
|
||||
|
||||
|
|
@ -129,6 +136,7 @@ class SpacePresenter(
|
|||
joinActions = joinActions.toImmutableMap(),
|
||||
acceptDeclineInviteState = acceptDeclineInviteState,
|
||||
topicViewerState = topicViewerState,
|
||||
canAccessSpaceSettings = isSpaceSettingsEnabled,
|
||||
eventSink = ::handleEvent,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ data class SpaceState(
|
|||
val joinActions: ImmutableMap<RoomId, AsyncAction<Unit>>,
|
||||
val acceptDeclineInviteState: AcceptDeclineInviteState,
|
||||
val topicViewerState: TopicViewerState,
|
||||
val canAccessSpaceSettings: Boolean,
|
||||
val eventSink: (SpaceEvents) -> Unit
|
||||
) {
|
||||
fun isJoining(spaceId: RoomId): Boolean = joinActions[spaceId] == AsyncAction.Loading
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ fun aSpaceState(
|
|||
hasMoreToLoad: Boolean = true,
|
||||
acceptDeclineInviteState: AcceptDeclineInviteState = anAcceptDeclineInviteState(),
|
||||
topicViewerState: TopicViewerState = TopicViewerState.Hidden,
|
||||
canAccessSpaceSettings: Boolean = true,
|
||||
eventSink: (SpaceEvents) -> Unit = { },
|
||||
) = SpaceState(
|
||||
currentSpace = parentSpace,
|
||||
|
|
@ -63,6 +64,7 @@ fun aSpaceState(
|
|||
joinActions = joinActions.toImmutableMap(),
|
||||
acceptDeclineInviteState = acceptDeclineInviteState,
|
||||
topicViewerState = topicViewerState,
|
||||
canAccessSpaceSettings = canAccessSpaceSettings,
|
||||
eventSink = eventSink,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ fun SpaceView(
|
|||
topBar = {
|
||||
SpaceViewTopBar(
|
||||
currentSpace = state.currentSpace,
|
||||
canAccessSpaceSettings = state.canAccessSpaceSettings,
|
||||
onBackClick = onBackClick,
|
||||
onLeaveSpaceClick = onLeaveSpaceClick,
|
||||
onShareSpace = onShareSpace,
|
||||
|
|
@ -255,6 +256,7 @@ private fun LoadingMoreIndicator(
|
|||
@Composable
|
||||
private fun SpaceViewTopBar(
|
||||
currentSpace: SpaceRoom?,
|
||||
canAccessSpaceSettings: Boolean,
|
||||
onBackClick: () -> Unit,
|
||||
onLeaveSpaceClick: () -> Unit,
|
||||
onDetailsClick: () -> Unit,
|
||||
|
|
@ -275,8 +277,7 @@ private fun SpaceViewTopBar(
|
|||
avatarData = currentSpace.getAvatarData(AvatarSize.TimelineRoom),
|
||||
modifier = Modifier
|
||||
.clip(roundedCornerShape)
|
||||
// TODO enable when screen ready for space
|
||||
.clickable(enabled = false, onClick = onDetailsClick)
|
||||
.clickable(enabled = canAccessSpaceSettings, onClick = onDetailsClick)
|
||||
)
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -75,6 +75,12 @@ enum class FeatureFlags(
|
|||
title = "Spaces",
|
||||
defaultValue = { true },
|
||||
isFinished = true,
|
||||
),
|
||||
SpaceSettings(
|
||||
key = "feature.spaceSettings",
|
||||
title = "Space settings",
|
||||
description = "Allow managing space settings such details, permissions and privacy.",
|
||||
defaultValue = { true },
|
||||
isFinished = false,
|
||||
),
|
||||
PrintLogsToLogcat(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue