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