From bb9e01a9f83eaf5b0830f27fae9a012404ea6233 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 18 Mar 2025 16:25:07 +0100 Subject: [PATCH] Fix preview issue. TimelineItemEventForTimestampViewProvider can now have event content which is not TimelineItemTextContent --- .../TimelineItemEventRowTimestampPreview.kt | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemEventRowTimestampPreview.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemEventRowTimestampPreview.kt index 12a6125404..8933538b8a 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemEventRowTimestampPreview.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemEventRowTimestampPreview.kt @@ -22,18 +22,25 @@ internal fun TimelineItemEventRowTimestampPreview( @PreviewParameter(TimelineItemEventForTimestampViewProvider::class) event: TimelineItem.Event ) = ElementPreview { Column { - val oldContent = event.content as TimelineItemTextContent - listOf( - "Text", - "Text longer, displayed on 1 line", - "Text which should be rendered on several lines", - ).forEach { str -> - ATimelineItemEventRow( - event = event.copy( - content = oldContent.copy( - body = str, - pillifiedBody = str, + when (event.content) { + is TimelineItemTextContent -> listOf( + "Text", + "Text longer, displayed on 1 line", + "Text which should be rendered on several lines", + ).forEach { str -> + ATimelineItemEventRow( + event = event.copy( + content = event.content.copy( + body = str, + pillifiedBody = str, + ), + reactionsState = aTimelineItemReactions(count = 0), ), + ) + } + else -> ATimelineItemEventRow( + event = event.copy( + content = event.content, reactionsState = aTimelineItemReactions(count = 0), ), )