mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-05 12:54:35 +00:00
ReactionSummaryEvents -> ReactionSummaryEvent
This commit is contained in:
+2
-2
@@ -30,7 +30,7 @@ import io.element.android.features.messages.impl.timeline.aTimelineItemList
|
|||||||
import io.element.android.features.messages.impl.timeline.aTimelineState
|
import io.element.android.features.messages.impl.timeline.aTimelineState
|
||||||
import io.element.android.features.messages.impl.timeline.components.customreaction.CustomReactionEvent
|
import io.element.android.features.messages.impl.timeline.components.customreaction.CustomReactionEvent
|
||||||
import io.element.android.features.messages.impl.timeline.components.customreaction.CustomReactionState
|
import io.element.android.features.messages.impl.timeline.components.customreaction.CustomReactionState
|
||||||
import io.element.android.features.messages.impl.timeline.components.reactionsummary.ReactionSummaryEvents
|
import io.element.android.features.messages.impl.timeline.components.reactionsummary.ReactionSummaryEvent
|
||||||
import io.element.android.features.messages.impl.timeline.components.reactionsummary.ReactionSummaryState
|
import io.element.android.features.messages.impl.timeline.components.reactionsummary.ReactionSummaryState
|
||||||
import io.element.android.features.messages.impl.timeline.components.receipt.bottomsheet.ReadReceiptBottomSheetEvents
|
import io.element.android.features.messages.impl.timeline.components.receipt.bottomsheet.ReadReceiptBottomSheetEvents
|
||||||
import io.element.android.features.messages.impl.timeline.components.receipt.bottomsheet.ReadReceiptBottomSheetState
|
import io.element.android.features.messages.impl.timeline.components.receipt.bottomsheet.ReadReceiptBottomSheetState
|
||||||
@@ -187,7 +187,7 @@ fun aUserEventPermissions(
|
|||||||
|
|
||||||
fun aReactionSummaryState(
|
fun aReactionSummaryState(
|
||||||
target: ReactionSummaryState.Summary? = null,
|
target: ReactionSummaryState.Summary? = null,
|
||||||
eventSink: (ReactionSummaryEvents) -> Unit = {}
|
eventSink: (ReactionSummaryEvent) -> Unit = {}
|
||||||
) = ReactionSummaryState(
|
) = ReactionSummaryState(
|
||||||
target = target,
|
target = target,
|
||||||
eventSink = eventSink,
|
eventSink = eventSink,
|
||||||
|
|||||||
+2
-2
@@ -76,7 +76,7 @@ import io.element.android.features.messages.impl.timeline.aTimelineItemEvent
|
|||||||
import io.element.android.features.messages.impl.timeline.aTimelineState
|
import io.element.android.features.messages.impl.timeline.aTimelineState
|
||||||
import io.element.android.features.messages.impl.timeline.components.customreaction.CustomReactionBottomSheet
|
import io.element.android.features.messages.impl.timeline.components.customreaction.CustomReactionBottomSheet
|
||||||
import io.element.android.features.messages.impl.timeline.components.customreaction.CustomReactionEvent
|
import io.element.android.features.messages.impl.timeline.components.customreaction.CustomReactionEvent
|
||||||
import io.element.android.features.messages.impl.timeline.components.reactionsummary.ReactionSummaryEvents
|
import io.element.android.features.messages.impl.timeline.components.reactionsummary.ReactionSummaryEvent
|
||||||
import io.element.android.features.messages.impl.timeline.components.reactionsummary.ReactionSummaryView
|
import io.element.android.features.messages.impl.timeline.components.reactionsummary.ReactionSummaryView
|
||||||
import io.element.android.features.messages.impl.timeline.components.receipt.bottomsheet.ReadReceiptBottomSheet
|
import io.element.android.features.messages.impl.timeline.components.receipt.bottomsheet.ReadReceiptBottomSheet
|
||||||
import io.element.android.features.messages.impl.timeline.components.receipt.bottomsheet.ReadReceiptBottomSheetEvents
|
import io.element.android.features.messages.impl.timeline.components.receipt.bottomsheet.ReadReceiptBottomSheetEvents
|
||||||
@@ -187,7 +187,7 @@ fun MessagesView(
|
|||||||
|
|
||||||
fun onEmojiReactionLongClick(emoji: String, event: TimelineItem.Event) {
|
fun onEmojiReactionLongClick(emoji: String, event: TimelineItem.Event) {
|
||||||
if (event.eventId == null) return
|
if (event.eventId == null) return
|
||||||
state.reactionSummaryState.eventSink(ReactionSummaryEvents.ShowReactionSummary(event.eventId, event.reactionsState.reactions, emoji))
|
state.reactionSummaryState.eventSink(ReactionSummaryEvent.ShowReactionSummary(event.eventId, event.reactionsState.reactions, emoji))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onMoreReactionsClick(event: TimelineItem.Event) {
|
fun onMoreReactionsClick(event: TimelineItem.Event) {
|
||||||
|
|||||||
+3
-3
@@ -11,7 +11,7 @@ package io.element.android.features.messages.impl.timeline.components.reactionsu
|
|||||||
import io.element.android.features.messages.impl.timeline.model.AggregatedReaction
|
import io.element.android.features.messages.impl.timeline.model.AggregatedReaction
|
||||||
import io.element.android.libraries.matrix.api.core.EventId
|
import io.element.android.libraries.matrix.api.core.EventId
|
||||||
|
|
||||||
sealed interface ReactionSummaryEvents {
|
sealed interface ReactionSummaryEvent {
|
||||||
data object Clear : ReactionSummaryEvents
|
data object Clear : ReactionSummaryEvent
|
||||||
data class ShowReactionSummary(val eventId: EventId, val reactions: List<AggregatedReaction>, val selectedKey: String) : ReactionSummaryEvents
|
data class ShowReactionSummary(val eventId: EventId, val reactions: List<AggregatedReaction>, val selectedKey: String) : ReactionSummaryEvent
|
||||||
}
|
}
|
||||||
+3
-3
@@ -37,14 +37,14 @@ class ReactionSummaryPresenter(
|
|||||||
}
|
}
|
||||||
val targetWithAvatars = populateSenderAvatars(members = membersState.roomMembers().orEmpty().toImmutableList(), summary = target.value)
|
val targetWithAvatars = populateSenderAvatars(members = membersState.roomMembers().orEmpty().toImmutableList(), summary = target.value)
|
||||||
|
|
||||||
fun handleEvent(event: ReactionSummaryEvents) {
|
fun handleEvent(event: ReactionSummaryEvent) {
|
||||||
when (event) {
|
when (event) {
|
||||||
is ReactionSummaryEvents.ShowReactionSummary -> target.value = ReactionSummaryState.Summary(
|
is ReactionSummaryEvent.ShowReactionSummary -> target.value = ReactionSummaryState.Summary(
|
||||||
reactions = event.reactions.toImmutableList(),
|
reactions = event.reactions.toImmutableList(),
|
||||||
selectedKey = event.selectedKey,
|
selectedKey = event.selectedKey,
|
||||||
selectedEventId = event.eventId
|
selectedEventId = event.eventId
|
||||||
)
|
)
|
||||||
ReactionSummaryEvents.Clear -> target.value = null
|
ReactionSummaryEvent.Clear -> target.value = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ReactionSummaryState(
|
return ReactionSummaryState(
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ import kotlinx.collections.immutable.ImmutableList
|
|||||||
|
|
||||||
data class ReactionSummaryState(
|
data class ReactionSummaryState(
|
||||||
val target: Summary?,
|
val target: Summary?,
|
||||||
val eventSink: (ReactionSummaryEvents) -> Unit
|
val eventSink: (ReactionSummaryEvent) -> Unit
|
||||||
) {
|
) {
|
||||||
data class Summary(
|
data class Summary(
|
||||||
val reactions: ImmutableList<AggregatedReaction>,
|
val reactions: ImmutableList<AggregatedReaction>,
|
||||||
|
|||||||
+1
-1
@@ -84,7 +84,7 @@ fun ReactionSummaryView(
|
|||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
fun onDismiss() {
|
fun onDismiss() {
|
||||||
state.eventSink(ReactionSummaryEvents.Clear)
|
state.eventSink(ReactionSummaryEvent.Clear)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.target != null) {
|
if (state.target != null) {
|
||||||
|
|||||||
+3
-3
@@ -48,7 +48,7 @@ import io.element.android.features.messages.impl.timeline.aTimelineRoomInfo
|
|||||||
import io.element.android.features.messages.impl.timeline.aTimelineState
|
import io.element.android.features.messages.impl.timeline.aTimelineState
|
||||||
import io.element.android.features.messages.impl.timeline.components.customreaction.CustomReactionEvent
|
import io.element.android.features.messages.impl.timeline.components.customreaction.CustomReactionEvent
|
||||||
import io.element.android.features.messages.impl.timeline.components.customreaction.CustomReactionState
|
import io.element.android.features.messages.impl.timeline.components.customreaction.CustomReactionState
|
||||||
import io.element.android.features.messages.impl.timeline.components.reactionsummary.ReactionSummaryEvents
|
import io.element.android.features.messages.impl.timeline.components.reactionsummary.ReactionSummaryEvent
|
||||||
import io.element.android.features.messages.impl.timeline.components.receipt.aReadReceiptData
|
import io.element.android.features.messages.impl.timeline.components.receipt.aReadReceiptData
|
||||||
import io.element.android.features.messages.impl.timeline.components.receipt.bottomsheet.ReadReceiptBottomSheetEvents
|
import io.element.android.features.messages.impl.timeline.components.receipt.bottomsheet.ReadReceiptBottomSheetEvents
|
||||||
import io.element.android.features.messages.impl.timeline.model.TimelineItem
|
import io.element.android.features.messages.impl.timeline.model.TimelineItem
|
||||||
@@ -406,7 +406,7 @@ class MessagesViewTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `long clicking on a reaction emits the expected Event`() {
|
fun `long clicking on a reaction emits the expected Event`() {
|
||||||
val eventsRecorder = EventsRecorder<ReactionSummaryEvents>()
|
val eventsRecorder = EventsRecorder<ReactionSummaryEvent>()
|
||||||
val state = aMessagesState(
|
val state = aMessagesState(
|
||||||
timelineState = aTimelineState(
|
timelineState = aTimelineState(
|
||||||
timelineItems = aTimelineItemList(aTimelineItemTextContent()),
|
timelineItems = aTimelineItemList(aTimelineItemTextContent()),
|
||||||
@@ -424,7 +424,7 @@ class MessagesViewTest {
|
|||||||
text = "👍️",
|
text = "👍️",
|
||||||
useUnmergedTree = true,
|
useUnmergedTree = true,
|
||||||
).onFirst().performTouchInput { longClick() }
|
).onFirst().performTouchInput { longClick() }
|
||||||
eventsRecorder.assertSingle(ReactionSummaryEvents.ShowReactionSummary(timelineItem.eventId!!, timelineItem.reactionsState.reactions, "👍️"))
|
eventsRecorder.assertSingle(ReactionSummaryEvent.ShowReactionSummary(timelineItem.eventId!!, timelineItem.reactionsState.reactions, "👍️"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
+2
-2
@@ -32,7 +32,7 @@ class ReactionSummaryPresenterTest {
|
|||||||
|
|
||||||
private val aggregatedReaction = anAggregatedReaction(userId = A_USER_ID, key = "👍", isHighlighted = true)
|
private val aggregatedReaction = anAggregatedReaction(userId = A_USER_ID, key = "👍", isHighlighted = true)
|
||||||
private val roomMember = aRoomMember(userId = A_USER_ID, avatarUrl = AN_AVATAR_URL, displayName = A_USER_NAME)
|
private val roomMember = aRoomMember(userId = A_USER_ID, avatarUrl = AN_AVATAR_URL, displayName = A_USER_NAME)
|
||||||
private val summaryEvent = ReactionSummaryEvents.ShowReactionSummary(AN_EVENT_ID, listOf(aggregatedReaction), aggregatedReaction.key)
|
private val summaryEvent = ReactionSummaryEvent.ShowReactionSummary(AN_EVENT_ID, listOf(aggregatedReaction), aggregatedReaction.key)
|
||||||
private val room = FakeBaseRoom().apply {
|
private val room = FakeBaseRoom().apply {
|
||||||
givenRoomMembersState(RoomMembersState.Ready(persistentListOf(roomMember)))
|
givenRoomMembersState(RoomMembersState.Ready(persistentListOf(roomMember)))
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ class ReactionSummaryPresenterTest {
|
|||||||
initialState.eventSink(summaryEvent)
|
initialState.eventSink(summaryEvent)
|
||||||
assertThat(awaitItem().target).isNotNull()
|
assertThat(awaitItem().target).isNotNull()
|
||||||
|
|
||||||
initialState.eventSink(ReactionSummaryEvents.Clear)
|
initialState.eventSink(ReactionSummaryEvent.Clear)
|
||||||
assertThat(awaitItem().target).isNull()
|
assertThat(awaitItem().target).isNull()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user