Show "View Event" if the developer mode is enabled.
This commit is contained in:
parent
bf67c6e349
commit
1a6641a5f7
3 changed files with 33 additions and 27 deletions
|
|
@ -18,6 +18,7 @@ package io.element.android.features.messages.impl.actionlist
|
|||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
|
|
@ -30,15 +31,15 @@ import io.element.android.features.messages.impl.timeline.model.event.TimelineIt
|
|||
import io.element.android.features.messages.impl.timeline.model.event.TimelineItemStateContent
|
||||
import io.element.android.features.messages.impl.timeline.model.event.canBeCopied
|
||||
import io.element.android.features.messages.impl.timeline.model.event.canReact
|
||||
import io.element.android.features.preferences.api.store.PreferencesStore
|
||||
import io.element.android.libraries.architecture.Presenter
|
||||
import io.element.android.libraries.core.meta.BuildMeta
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
||||
class ActionListPresenter @Inject constructor(
|
||||
private val buildMeta: BuildMeta,
|
||||
private val preferencesStore: PreferencesStore,
|
||||
) : Presenter<ActionListState> {
|
||||
|
||||
@Composable
|
||||
|
|
@ -49,6 +50,8 @@ class ActionListPresenter @Inject constructor(
|
|||
mutableStateOf(ActionListState.Target.None)
|
||||
}
|
||||
|
||||
val isDeveloperModeEnabled by preferencesStore.isDevelopModeEnabledFlow().collectAsState(initial = false)
|
||||
|
||||
val displayEmojiReactions by remember {
|
||||
derivedStateOf {
|
||||
val event = (target.value as? ActionListState.Target.Success)?.event
|
||||
|
|
@ -63,6 +66,7 @@ class ActionListPresenter @Inject constructor(
|
|||
timelineItem = event.event,
|
||||
userCanRedact = event.canRedact,
|
||||
userCanSendMessage = event.canSendMessage,
|
||||
isDeveloperModeEnabled = isDeveloperModeEnabled,
|
||||
target = target,
|
||||
)
|
||||
}
|
||||
|
|
@ -79,13 +83,14 @@ class ActionListPresenter @Inject constructor(
|
|||
timelineItem: TimelineItem.Event,
|
||||
userCanRedact: Boolean,
|
||||
userCanSendMessage: Boolean,
|
||||
isDeveloperModeEnabled: Boolean,
|
||||
target: MutableState<ActionListState.Target>
|
||||
) = launch {
|
||||
target.value = ActionListState.Target.Loading(timelineItem)
|
||||
val actions =
|
||||
when (timelineItem.content) {
|
||||
is TimelineItemRedactedContent -> {
|
||||
if (buildMeta.isDebuggable) {
|
||||
if (isDeveloperModeEnabled) {
|
||||
listOf(TimelineItemAction.ViewSource)
|
||||
} else {
|
||||
emptyList()
|
||||
|
|
@ -94,7 +99,7 @@ class ActionListPresenter @Inject constructor(
|
|||
is TimelineItemStateContent -> {
|
||||
buildList {
|
||||
add(TimelineItemAction.Copy)
|
||||
if (buildMeta.isDebuggable) {
|
||||
if (isDeveloperModeEnabled) {
|
||||
add(TimelineItemAction.ViewSource)
|
||||
}
|
||||
}
|
||||
|
|
@ -115,7 +120,7 @@ class ActionListPresenter @Inject constructor(
|
|||
if (timelineItem.content.canBeCopied()) {
|
||||
add(TimelineItemAction.Copy)
|
||||
}
|
||||
if (buildMeta.isDebuggable) {
|
||||
if (isDeveloperModeEnabled) {
|
||||
add(TimelineItemAction.ViewSource)
|
||||
}
|
||||
if (!timelineItem.isMine) {
|
||||
|
|
@ -144,7 +149,7 @@ class ActionListPresenter @Inject constructor(
|
|||
if (timelineItem.content.canBeCopied()) {
|
||||
add(TimelineItemAction.Copy)
|
||||
}
|
||||
if (buildMeta.isDebuggable) {
|
||||
if (isDeveloperModeEnabled) {
|
||||
add(TimelineItemAction.ViewSource)
|
||||
}
|
||||
if (!timelineItem.isMine) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue