Show the right image when opening one that has not finished sending (#7359)

* Show the right image when opening one that has not finished sending

* Reuse the timeline media gallery for events that have no event id
This commit is contained in:
hayyaksi
2026-08-20 12:16:13 +03:00
committed by GitHub
parent 7ba29d8a5e
commit 2525019ca1
3 changed files with 30 additions and 3 deletions
@@ -178,8 +178,8 @@ fun MessagesView(
fun onContentClick(event: TimelineItem.Event) {
Timber.v("onMessageClick= ${event.id}")
val eventId = event.eventId ?: return
if (eventContentValidationState[eventId].getCurrentOverallState() != ContentValidationValue.Valid) return
val eventId = event.eventId
if (eventId != null && eventContentValidationState[eventId].getCurrentOverallState() != ContentValidationValue.Valid) return
val hideKeyboard = onEventContentClick(state.timelineState.isLive, event)
if (hideKeyboard) {
@@ -176,6 +176,33 @@ class MessagesViewTest : RobolectricTest() {
callback.assertSuccess()
}
@Test
fun `clicking on an Event which has not been sent yet invoke expected callback`() = runAndroidComposeUiTest {
val eventsRecorder = EventsRecorder<MessagesEvent>(expectEvents = false)
val localEcho = aTimelineItemEvent(
isMine = true,
content = aTimelineItemTextContent(),
).copy(eventId = null)
val state = aMessagesState(
timelineState = aTimelineState(
timelineItems = persistentListOf(localEcho),
),
eventSink = eventsRecorder
)
val callback = EnsureCalledOnceWithTwoParamsAndResult(
expectedParam1 = true,
expectedParam2 = localEcho,
result = true,
)
setMessagesView(
state = state,
onEventClick = callback,
)
// Cannot perform click on "Text", it's not detected. Use tag instead
onAllNodesWithTag(TestTags.messageBubble.value).onFirst().performClick()
callback.assertSuccess()
}
@Test
fun `long clicking on an Event emits the expected Event userHasPermissionToSendMessage`() {
`long clicking on an Event emits the expected Event`(userHasPermissionToSendMessage = true)
@@ -92,7 +92,7 @@ class MediaViewerNode(
is MediaViewerEntryPoint.Params.RoomMedia -> {
val eventId = inputs.eventId
if (eventId == null) {
// Should not happen
// Local echo, the viewer will not be focused on the item
timelineMediaGalleryDataSource
} else {
// Can we use a specific timeline?