Rename hideContent to hideMediaContent
This commit is contained in:
parent
fafd5d4871
commit
b889e8681c
14 changed files with 42 additions and 42 deletions
|
|
@ -402,7 +402,7 @@ class MessagesPresenter @AssistedInject constructor(
|
|||
val replyToDetails = loadReplyDetails(targetEvent.eventId).map(permalinkParser)
|
||||
val composerMode = MessageComposerMode.Reply(
|
||||
replyToDetails = replyToDetails,
|
||||
hideImage = timelineProtectionState.hideContent(targetEvent.eventId),
|
||||
hideImage = timelineProtectionState.hideMediaContent(targetEvent.eventId),
|
||||
)
|
||||
composerState.eventSink(
|
||||
MessageComposerEvents.SetMode(composerMode)
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ private fun TimelineItemEventContentViewWrapper(
|
|||
} else {
|
||||
TimelineItemEventContentView(
|
||||
content = event.content,
|
||||
hideContent = timelineProtectionState.hideContent(event.eventId),
|
||||
hideMediaContent = timelineProtectionState.hideMediaContent(event.eventId),
|
||||
onShowClick = { timelineProtectionState.eventSink(TimelineProtectionEvent.ShowContent(event.eventId)) },
|
||||
onLinkClick = onLinkClick,
|
||||
eventSink = { },
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ fun TimelineItemEventRow(
|
|||
eventContentView: @Composable (Modifier, (ContentAvoidingLayoutData) -> Unit) -> Unit = { contentModifier, onContentLayoutChange ->
|
||||
TimelineItemEventContentView(
|
||||
content = event.content,
|
||||
hideContent = timelineProtectionState.hideContent(event.eventId),
|
||||
hideMediaContent = timelineProtectionState.hideMediaContent(event.eventId),
|
||||
onShowClick = { timelineProtectionState.eventSink(TimelineProtectionEvent.ShowContent(event.eventId)) },
|
||||
onLinkClick = onLinkClick,
|
||||
eventSink = eventSink,
|
||||
|
|
@ -572,7 +572,7 @@ private fun MessageEventBubbleContent(
|
|||
.clickable(onClick = inReplyToClick)
|
||||
InReplyToView(
|
||||
inReplyTo = inReplyTo,
|
||||
hideImage = timelineProtectionState.hideContent(inReplyTo.eventId()),
|
||||
hideImage = timelineProtectionState.hideMediaContent(inReplyTo.eventId()),
|
||||
modifier = inReplyToModifier,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ fun TimelineItemGroupedEventsRow(
|
|||
{ event, contentModifier, onContentLayoutChange ->
|
||||
TimelineItemEventContentView(
|
||||
content = event.content,
|
||||
hideContent = timelineProtectionState.hideContent(event.eventId),
|
||||
hideMediaContent = timelineProtectionState.hideMediaContent(event.eventId),
|
||||
onShowClick = { timelineProtectionState.eventSink(TimelineProtectionEvent.ShowContent(event.eventId)) },
|
||||
onLinkClick = onLinkClick,
|
||||
eventSink = eventSink,
|
||||
|
|
@ -120,7 +120,7 @@ private fun TimelineItemGroupedEventsRowContent(
|
|||
{ event, contentModifier, onContentLayoutChange ->
|
||||
TimelineItemEventContentView(
|
||||
content = event.content,
|
||||
hideContent = timelineProtectionState.hideContent(event.eventId),
|
||||
hideMediaContent = timelineProtectionState.hideMediaContent(event.eventId),
|
||||
onShowClick = { timelineProtectionState.eventSink(TimelineProtectionEvent.ShowContent(event.eventId)) },
|
||||
onLinkClick = onLinkClick,
|
||||
eventSink = eventSink,
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ internal fun TimelineItemRow(
|
|||
{ event, contentModifier, onContentLayoutChange ->
|
||||
TimelineItemEventContentView(
|
||||
content = event.content,
|
||||
hideContent = timelineProtectionState.hideContent(event.eventId),
|
||||
hideMediaContent = timelineProtectionState.hideMediaContent(event.eventId),
|
||||
onShowClick = { timelineProtectionState.eventSink(TimelineProtectionEvent.ShowContent(event.eventId)) },
|
||||
onLinkClick = onLinkClick,
|
||||
eventSink = eventSink,
|
||||
|
|
@ -118,7 +118,7 @@ internal fun TimelineItemRow(
|
|||
timelineProtectionState = timelineProtectionState,
|
||||
isLastOutgoingMessage = isLastOutgoingMessage,
|
||||
isHighlighted = timelineItem.isEvent(focusedEventId),
|
||||
onClick = if (timelineProtectionState.hideContent(timelineItem.eventId) && timelineItem.mustBeProtected()) {
|
||||
onClick = if (timelineProtectionState.hideMediaContent(timelineItem.eventId) && timelineItem.mustBeProtected()) {
|
||||
{}
|
||||
} else {
|
||||
{ onClick(timelineItem) }
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ fun TimelineItemStateEventRow(
|
|||
TimelineItemEventContentView(
|
||||
content = event.content,
|
||||
onLinkClick = {},
|
||||
hideContent = false,
|
||||
hideMediaContent = false,
|
||||
onShowClick = {},
|
||||
eventSink = eventSink,
|
||||
modifier = Modifier.defaultTimelineContentPadding()
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import io.element.android.libraries.architecture.Presenter
|
|||
@Composable
|
||||
fun TimelineItemEventContentView(
|
||||
content: TimelineItemEventContent,
|
||||
hideContent: Boolean,
|
||||
hideMediaContent: Boolean,
|
||||
onShowClick: () -> Unit,
|
||||
onLinkClick: (url: String) -> Unit,
|
||||
eventSink: (TimelineEvents.EventFromTimelineItem) -> Unit,
|
||||
|
|
@ -71,20 +71,20 @@ fun TimelineItemEventContentView(
|
|||
)
|
||||
is TimelineItemImageContent -> TimelineItemImageView(
|
||||
content = content,
|
||||
hideContent = hideContent,
|
||||
hideMediaContent = hideMediaContent,
|
||||
onShowClick = onShowClick,
|
||||
onContentLayoutChange = onContentLayoutChange,
|
||||
modifier = modifier,
|
||||
)
|
||||
is TimelineItemStickerContent -> TimelineItemStickerView(
|
||||
content = content,
|
||||
hideContent = hideContent,
|
||||
hideMediaContent = hideMediaContent,
|
||||
onShowClick = onShowClick,
|
||||
modifier = modifier,
|
||||
)
|
||||
is TimelineItemVideoContent -> TimelineItemVideoView(
|
||||
content = content,
|
||||
hideContent = hideContent,
|
||||
hideMediaContent = hideMediaContent,
|
||||
onShowClick = onShowClick,
|
||||
onContentLayoutChange = onContentLayoutChange,
|
||||
modifier = modifier
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ import io.element.android.wysiwyg.compose.EditorStyledText
|
|||
@Composable
|
||||
fun TimelineItemImageView(
|
||||
content: TimelineItemImageContent,
|
||||
hideContent: Boolean,
|
||||
hideMediaContent: Boolean,
|
||||
onShowClick: () -> Unit,
|
||||
onContentLayoutChange: (ContentAvoidingLayoutData) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
|
|
@ -80,7 +80,7 @@ fun TimelineItemImageView(
|
|||
aspectRatio = content.aspectRatio,
|
||||
) {
|
||||
ProtectedView(
|
||||
hideContent = hideContent,
|
||||
hideContent = hideMediaContent,
|
||||
onShowClick = onShowClick,
|
||||
) {
|
||||
var isLoaded by remember { mutableStateOf(false) }
|
||||
|
|
@ -133,7 +133,7 @@ fun TimelineItemImageView(
|
|||
internal fun TimelineItemImageViewPreview(@PreviewParameter(TimelineItemImageContentProvider::class) content: TimelineItemImageContent) = ElementPreview {
|
||||
TimelineItemImageView(
|
||||
content = content,
|
||||
hideContent = false,
|
||||
hideMediaContent = false,
|
||||
onShowClick = {},
|
||||
onContentLayoutChange = {},
|
||||
)
|
||||
|
|
@ -141,10 +141,10 @@ internal fun TimelineItemImageViewPreview(@PreviewParameter(TimelineItemImageCon
|
|||
|
||||
@PreviewsDayNight
|
||||
@Composable
|
||||
internal fun TimelineItemImageViewHideContentPreview() = ElementPreview {
|
||||
internal fun TimelineItemImageViewHideMediaContentPreview() = ElementPreview {
|
||||
TimelineItemImageView(
|
||||
content = aTimelineItemImageContent(),
|
||||
hideContent = true,
|
||||
hideMediaContent = true,
|
||||
onShowClick = {},
|
||||
onContentLayoutChange = {},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ private const val STICKER_SIZE_IN_DP = 128
|
|||
@Composable
|
||||
fun TimelineItemStickerView(
|
||||
content: TimelineItemStickerContent,
|
||||
hideContent: Boolean,
|
||||
hideMediaContent: Boolean,
|
||||
onShowClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
|
|
@ -54,7 +54,7 @@ fun TimelineItemStickerView(
|
|||
maxHeight = STICKER_SIZE_IN_DP,
|
||||
) {
|
||||
ProtectedView(
|
||||
hideContent = hideContent,
|
||||
hideContent = hideMediaContent,
|
||||
onShowClick = onShowClick,
|
||||
) {
|
||||
var isLoaded by remember { mutableStateOf(false) }
|
||||
|
|
@ -84,7 +84,7 @@ fun TimelineItemStickerView(
|
|||
internal fun TimelineItemStickerViewPreview(@PreviewParameter(TimelineItemStickerContentProvider::class) content: TimelineItemStickerContent) = ElementPreview {
|
||||
TimelineItemStickerView(
|
||||
content = content,
|
||||
hideContent = false,
|
||||
hideMediaContent = false,
|
||||
onShowClick = {},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ import io.element.android.wysiwyg.compose.EditorStyledText
|
|||
@Composable
|
||||
fun TimelineItemVideoView(
|
||||
content: TimelineItemVideoContent,
|
||||
hideContent: Boolean,
|
||||
hideMediaContent: Boolean,
|
||||
onShowClick: () -> Unit,
|
||||
onContentLayoutChange: (ContentAvoidingLayoutData) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
|
|
@ -87,7 +87,7 @@ fun TimelineItemVideoView(
|
|||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
ProtectedView(
|
||||
hideContent = hideContent,
|
||||
hideContent = hideMediaContent,
|
||||
onShowClick = onShowClick,
|
||||
) {
|
||||
var isLoaded by remember { mutableStateOf(false) }
|
||||
|
|
@ -151,7 +151,7 @@ fun TimelineItemVideoView(
|
|||
internal fun TimelineItemVideoViewPreview(@PreviewParameter(TimelineItemVideoContentProvider::class) content: TimelineItemVideoContent) = ElementPreview {
|
||||
TimelineItemVideoView(
|
||||
content = content,
|
||||
hideContent = false,
|
||||
hideMediaContent = false,
|
||||
onShowClick = {},
|
||||
onContentLayoutChange = {},
|
||||
)
|
||||
|
|
@ -159,10 +159,10 @@ internal fun TimelineItemVideoViewPreview(@PreviewParameter(TimelineItemVideoCon
|
|||
|
||||
@PreviewsDayNight
|
||||
@Composable
|
||||
internal fun TimelineItemVideoViewHideContentPreview() = ElementPreview {
|
||||
internal fun TimelineItemVideoViewHideMediaContentPreview() = ElementPreview {
|
||||
TimelineItemVideoView(
|
||||
content = aTimelineItemVideoContent(),
|
||||
hideContent = true,
|
||||
hideMediaContent = true,
|
||||
onShowClick = {},
|
||||
onContentLayoutChange = {},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -25,11 +25,11 @@ class TimelineProtectionPresenter @Inject constructor(
|
|||
) : Presenter<TimelineProtectionState> {
|
||||
@Composable
|
||||
override fun present(): TimelineProtectionState {
|
||||
val hideContent by appPreferencesStore.doesHideImagesAndVideosFlow().collectAsState(initial = false)
|
||||
val hideMediaContent by appPreferencesStore.doesHideImagesAndVideosFlow().collectAsState(initial = false)
|
||||
var allowedEvents by remember { mutableStateOf<Set<EventId>>(setOf()) }
|
||||
val protectionState by remember(hideContent) {
|
||||
val protectionState by remember(hideMediaContent) {
|
||||
derivedStateOf {
|
||||
if (hideContent) {
|
||||
if (hideMediaContent) {
|
||||
ProtectionState.RenderOnly(eventIds = allowedEvents.toImmutableSet())
|
||||
} else {
|
||||
ProtectionState.RenderAll
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ data class TimelineProtectionState(
|
|||
val protectionState: ProtectionState,
|
||||
val eventSink: (TimelineProtectionEvent) -> Unit,
|
||||
) {
|
||||
fun hideContent(eventId: EventId?) = when (protectionState) {
|
||||
fun hideMediaContent(eventId: EventId?) = when (protectionState) {
|
||||
is ProtectionState.RenderAll -> false
|
||||
is ProtectionState.RenderOnly -> eventId !in protectionState.eventIds
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,30 +15,30 @@ import org.junit.Test
|
|||
|
||||
class TimelineProtectionStateTest {
|
||||
@Test
|
||||
fun `when protectionState is RenderAll, hideContent always return null`() {
|
||||
fun `when protectionState is RenderAll, hideMediaContent always return null`() {
|
||||
val sut = aTimelineProtectionState(
|
||||
protectionState = ProtectionState.RenderAll
|
||||
)
|
||||
assertThat(sut.hideContent(null)).isFalse()
|
||||
assertThat(sut.hideContent(AN_EVENT_ID)).isFalse()
|
||||
assertThat(sut.hideMediaContent(null)).isFalse()
|
||||
assertThat(sut.hideMediaContent(AN_EVENT_ID)).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when protectionState is RenderOnly with empty set, hideContent always return true`() {
|
||||
fun `when protectionState is RenderOnly with empty set, hideMediaContent always return true`() {
|
||||
val sut = aTimelineProtectionState(
|
||||
protectionState = ProtectionState.RenderOnly(persistentSetOf())
|
||||
)
|
||||
assertThat(sut.hideContent(null)).isTrue()
|
||||
assertThat(sut.hideContent(AN_EVENT_ID)).isTrue()
|
||||
assertThat(sut.hideMediaContent(null)).isTrue()
|
||||
assertThat(sut.hideMediaContent(AN_EVENT_ID)).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when protectionState is RenderOnly with an Event, hideContent can return true or false`() {
|
||||
fun `when protectionState is RenderOnly with an Event, hideMediaContent can return true or false`() {
|
||||
val sut = aTimelineProtectionState(
|
||||
protectionState = ProtectionState.RenderOnly(persistentSetOf(AN_EVENT_ID))
|
||||
)
|
||||
assertThat(sut.hideContent(null)).isTrue()
|
||||
assertThat(sut.hideContent(AN_EVENT_ID)).isFalse()
|
||||
assertThat(sut.hideContent(AN_EVENT_ID_2)).isTrue()
|
||||
assertThat(sut.hideMediaContent(null)).isTrue()
|
||||
assertThat(sut.hideMediaContent(AN_EVENT_ID)).isFalse()
|
||||
assertThat(sut.hideMediaContent(AN_EVENT_ID_2)).isTrue()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,8 +118,8 @@ class KonsistPreviewTest {
|
|||
"TimelineItemEventRowWithReplyPreview",
|
||||
"TimelineItemGroupedEventsRowContentCollapsePreview",
|
||||
"TimelineItemGroupedEventsRowContentExpandedPreview",
|
||||
"TimelineItemImageViewHideContentPreview",
|
||||
"TimelineItemVideoViewHideContentPreview",
|
||||
"TimelineItemImageViewHideMediaContentPreview",
|
||||
"TimelineItemVideoViewHideMediaContentPreview",
|
||||
"TimelineItemVoiceViewUnifiedPreview",
|
||||
"TimelineVideoWithCaptionRowPreview",
|
||||
"TimelineViewMessageShieldPreview",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue