Thread decoration: add and branch isThreaded method
This commit is contained in:
@@ -111,6 +111,7 @@ internal fun aTimelineItemEvent(
|
||||
groupPosition: TimelineItemGroupPosition = TimelineItemGroupPosition.None,
|
||||
sendState: LocalEventSendState = LocalEventSendState.Sent(eventId),
|
||||
inReplyTo: InReplyTo? = null,
|
||||
isThreaded: Boolean = false,
|
||||
debugInfo: TimelineItemDebugInfo = aTimelineItemDebugInfo(),
|
||||
timelineItemReactions: TimelineItemReactions = aTimelineItemReactions(),
|
||||
): TimelineItem.Event {
|
||||
@@ -129,6 +130,7 @@ internal fun aTimelineItemEvent(
|
||||
localSendState = sendState,
|
||||
inReplyTo = inReplyTo,
|
||||
debugInfo = debugInfo,
|
||||
isThreaded = isThreaded,
|
||||
origin = null
|
||||
)
|
||||
}
|
||||
|
||||
@@ -522,7 +522,7 @@ private fun MessageEventBubbleContent(
|
||||
}
|
||||
val replyToDetails = event.inReplyTo as? InReplyTo.Ready
|
||||
CommonLayout(
|
||||
showThreadDecoration = false,
|
||||
showThreadDecoration = event.isThreaded,
|
||||
timestampPosition = timestampPosition,
|
||||
inReplyToDetails = replyToDetails,
|
||||
modifier = bubbleModifier
|
||||
@@ -707,7 +707,7 @@ private fun ContentToPreviewWithReply() {
|
||||
body = "A long text which will be displayed on several lines and" +
|
||||
" hopefully can be manually adjusted to test different behaviors."
|
||||
),
|
||||
inReplyTo = aInReplyToReady(replyContent),
|
||||
inReplyTo = aInReplyToReady(replyContent, true),
|
||||
groupPosition = TimelineItemGroupPosition.First,
|
||||
),
|
||||
isHighlighted = false,
|
||||
@@ -729,7 +729,7 @@ private fun ContentToPreviewWithReply() {
|
||||
content = aTimelineItemImageContent().copy(
|
||||
aspectRatio = 5f
|
||||
),
|
||||
inReplyTo = aInReplyToReady(replyContent),
|
||||
inReplyTo = aInReplyToReady(replyContent, false),
|
||||
groupPosition = TimelineItemGroupPosition.Last,
|
||||
),
|
||||
isHighlighted = false,
|
||||
@@ -750,11 +750,12 @@ private fun ContentToPreviewWithReply() {
|
||||
}
|
||||
|
||||
private fun aInReplyToReady(
|
||||
replyContent: String
|
||||
replyContent: String,
|
||||
isThreaded: Boolean,
|
||||
): InReplyTo.Ready {
|
||||
return InReplyTo.Ready(
|
||||
eventId = EventId("\$event"),
|
||||
content = MessageContent(replyContent, null, false, TextMessageType(replyContent, null)),
|
||||
content = MessageContent(replyContent, null, false, isThreaded, TextMessageType(replyContent, null)),
|
||||
senderId = UserId("@Sender:domain"),
|
||||
senderDisplayName = "Sender",
|
||||
senderAvatarUrl = null,
|
||||
|
||||
@@ -71,6 +71,7 @@ class TimelineItemEventFactory @Inject constructor(
|
||||
url = senderAvatarUrl,
|
||||
size = AvatarSize.TimelineSender
|
||||
)
|
||||
currentTimelineItem.event
|
||||
return TimelineItem.Event(
|
||||
id = currentTimelineItem.uniqueId.toString(),
|
||||
eventId = currentTimelineItem.eventId,
|
||||
@@ -85,6 +86,7 @@ class TimelineItemEventFactory @Inject constructor(
|
||||
reactionsState = currentTimelineItem.computeReactionsState(),
|
||||
localSendState = currentTimelineItem.event.localSendState,
|
||||
inReplyTo = currentTimelineItem.event.inReplyTo(),
|
||||
isThreaded = currentTimelineItem.event.isThreaded(),
|
||||
debugInfo = currentTimelineItem.event.debugInfo,
|
||||
origin = currentTimelineItem.event.origin,
|
||||
)
|
||||
|
||||
@@ -66,6 +66,7 @@ sealed interface TimelineItem {
|
||||
val reactionsState: TimelineItemReactions,
|
||||
val localSendState: LocalEventSendState?,
|
||||
val inReplyTo: InReplyTo?,
|
||||
val isThreaded: Boolean,
|
||||
val debugInfo: TimelineItemDebugInfo,
|
||||
val origin: TimelineItemEventOrigin?,
|
||||
) : TimelineItem {
|
||||
|
||||
@@ -37,6 +37,7 @@ internal fun aMessageEvent(
|
||||
isMine: Boolean = true,
|
||||
content: TimelineItemEventContent = TimelineItemTextContent(body = A_MESSAGE, htmlDocument = null, isEdited = false),
|
||||
inReplyTo: InReplyTo? = null,
|
||||
isThreaded: Boolean = false,
|
||||
debugInfo: TimelineItemDebugInfo = aTimelineItemDebugInfo(),
|
||||
sendState: LocalEventSendState = LocalEventSendState.Sent(AN_EVENT_ID),
|
||||
) = TimelineItem.Event(
|
||||
@@ -52,5 +53,6 @@ internal fun aMessageEvent(
|
||||
localSendState = sendState,
|
||||
inReplyTo = inReplyTo,
|
||||
debugInfo = debugInfo,
|
||||
isThreaded = isThreaded,
|
||||
origin = null
|
||||
)
|
||||
|
||||
@@ -44,6 +44,7 @@ class TimelineItemGrouperTest {
|
||||
reactionsState = aTimelineItemReactions(count = 0),
|
||||
localSendState = LocalEventSendState.Sent(AN_EVENT_ID),
|
||||
inReplyTo = null,
|
||||
isThreaded = false,
|
||||
debugInfo = aTimelineItemDebugInfo(),
|
||||
origin = null
|
||||
)
|
||||
|
||||
@@ -32,6 +32,7 @@ data class MessageContent(
|
||||
val body: String,
|
||||
val inReplyTo: InReplyTo?,
|
||||
val isEdited: Boolean,
|
||||
val isThreaded: Boolean,
|
||||
val type: MessageType?
|
||||
) : EventContent
|
||||
|
||||
|
||||
@@ -40,6 +40,11 @@ data class EventTimelineItem(
|
||||
fun inReplyTo(): InReplyTo? {
|
||||
return (content as? MessageContent)?.inReplyTo
|
||||
}
|
||||
|
||||
fun isThreaded(): Boolean {
|
||||
return (content as? MessageContent)?.isThreaded ?: false
|
||||
}
|
||||
|
||||
fun hasNotLoadedInReplyTo(): Boolean {
|
||||
val details = inReplyTo()
|
||||
return details is InReplyTo.NotLoaded
|
||||
|
||||
@@ -68,6 +68,7 @@ class EventMessageMapper {
|
||||
body = it.body(),
|
||||
inReplyTo = inReplyToEvent,
|
||||
isEdited = it.isEdited(),
|
||||
isThreaded = it.isThreaded(),
|
||||
type = type
|
||||
)
|
||||
}
|
||||
|
||||
@@ -147,6 +147,7 @@ fun aMessageContent(
|
||||
body: String = "body",
|
||||
inReplyTo: InReplyTo? = null,
|
||||
isEdited: Boolean = false,
|
||||
isThreaded: Boolean = false,
|
||||
messageType: MessageType = TextMessageType(
|
||||
body = body,
|
||||
formatted = null
|
||||
@@ -155,6 +156,7 @@ fun aMessageContent(
|
||||
body = body,
|
||||
inReplyTo = inReplyTo,
|
||||
isEdited = isEdited,
|
||||
isThreaded = isThreaded,
|
||||
type = messageType
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user