Render edited caption.
This commit is contained in:
parent
7edfefe9f1
commit
3d87dae5c1
17 changed files with 38 additions and 13 deletions
|
|
@ -87,6 +87,7 @@ class TimelineItemContentMessageFactory @Inject constructor(
|
|||
filename = messageType.filename,
|
||||
caption = messageType.caption?.trimEnd(),
|
||||
formattedCaption = parseHtml(messageType.formattedCaption) ?: messageType.caption?.withLinks(),
|
||||
isEdited = content.isEdited,
|
||||
mediaSource = messageType.source,
|
||||
thumbnailSource = messageType.info?.thumbnailSource,
|
||||
mimeType = messageType.info?.mimetype ?: MimeTypes.OctetStream,
|
||||
|
|
@ -106,6 +107,7 @@ class TimelineItemContentMessageFactory @Inject constructor(
|
|||
filename = messageType.filename,
|
||||
caption = messageType.caption?.trimEnd(),
|
||||
formattedCaption = parseHtml(messageType.formattedCaption) ?: messageType.caption?.withLinks(),
|
||||
isEdited = content.isEdited,
|
||||
mediaSource = messageType.source,
|
||||
thumbnailSource = messageType.info?.thumbnailSource,
|
||||
mimeType = messageType.info?.mimetype ?: MimeTypes.OctetStream,
|
||||
|
|
@ -143,6 +145,7 @@ class TimelineItemContentMessageFactory @Inject constructor(
|
|||
filename = messageType.filename,
|
||||
caption = messageType.caption?.trimEnd(),
|
||||
formattedCaption = parseHtml(messageType.formattedCaption) ?: messageType.caption?.withLinks(),
|
||||
isEdited = content.isEdited,
|
||||
thumbnailSource = messageType.info?.thumbnailSource,
|
||||
videoSource = messageType.source,
|
||||
mimeType = messageType.info?.mimetype ?: MimeTypes.OctetStream,
|
||||
|
|
@ -162,6 +165,7 @@ class TimelineItemContentMessageFactory @Inject constructor(
|
|||
filename = messageType.filename,
|
||||
caption = messageType.caption?.trimEnd(),
|
||||
formattedCaption = parseHtml(messageType.formattedCaption) ?: messageType.caption?.withLinks(),
|
||||
isEdited = content.isEdited,
|
||||
mediaSource = messageType.source,
|
||||
duration = messageType.info?.duration ?: Duration.ZERO,
|
||||
mimeType = messageType.info?.mimetype ?: MimeTypes.OctetStream,
|
||||
|
|
@ -177,6 +181,7 @@ class TimelineItemContentMessageFactory @Inject constructor(
|
|||
filename = messageType.filename,
|
||||
caption = messageType.caption?.trimEnd(),
|
||||
formattedCaption = parseHtml(messageType.formattedCaption) ?: messageType.caption?.withLinks(),
|
||||
isEdited = content.isEdited,
|
||||
mediaSource = messageType.source,
|
||||
duration = messageType.info?.duration ?: Duration.ZERO,
|
||||
mimeType = messageType.info?.mimetype ?: MimeTypes.OctetStream,
|
||||
|
|
@ -188,6 +193,7 @@ class TimelineItemContentMessageFactory @Inject constructor(
|
|||
filename = messageType.filename,
|
||||
caption = messageType.caption?.trimEnd(),
|
||||
formattedCaption = parseHtml(messageType.formattedCaption) ?: messageType.caption?.withLinks(),
|
||||
isEdited = content.isEdited,
|
||||
mediaSource = messageType.source,
|
||||
duration = messageType.info?.duration ?: Duration.ZERO,
|
||||
mimeType = messageType.info?.mimetype ?: MimeTypes.OctetStream,
|
||||
|
|
@ -203,6 +209,7 @@ class TimelineItemContentMessageFactory @Inject constructor(
|
|||
filename = messageType.filename,
|
||||
caption = messageType.caption?.trimEnd(),
|
||||
formattedCaption = parseHtml(messageType.formattedCaption) ?: messageType.caption?.withLinks(),
|
||||
isEdited = content.isEdited,
|
||||
thumbnailSource = messageType.info?.thumbnailSource,
|
||||
fileSource = messageType.source,
|
||||
mimeType = messageType.info?.mimetype ?: MimeTypes.fromFileExtension(fileExtension),
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ class TimelineItemContentStickerFactory @Inject constructor(
|
|||
filename = content.filename,
|
||||
caption = content.body,
|
||||
formattedCaption = null,
|
||||
isEdited = false,
|
||||
mediaSource = content.source,
|
||||
thumbnailSource = content.info.thumbnailSource,
|
||||
mimeType = content.info.mimetype ?: MimeTypes.OctetStream,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ data class TimelineItemAudioContent(
|
|||
override val filename: String,
|
||||
override val caption: String?,
|
||||
override val formattedCaption: CharSequence?,
|
||||
override val isEdited: Boolean,
|
||||
val duration: Duration,
|
||||
val mediaSource: MediaSource,
|
||||
val mimeType: String,
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ fun aTimelineItemAudioContent(fileName: String = "A sound.mp3") = TimelineItemAu
|
|||
filename = fileName,
|
||||
caption = null,
|
||||
formattedCaption = null,
|
||||
isEdited = false,
|
||||
mimeType = MimeTypes.Mp3,
|
||||
formattedFileSize = "100kB",
|
||||
fileExtension = "mp3",
|
||||
|
|
|
|||
|
|
@ -14,8 +14,15 @@ sealed interface TimelineItemEventContent {
|
|||
val type: String
|
||||
}
|
||||
|
||||
interface TimelineItemEventMutableContent {
|
||||
/** Whether the event has been edited. */
|
||||
val isEdited: Boolean
|
||||
}
|
||||
|
||||
@Immutable
|
||||
sealed interface TimelineItemEventContentWithAttachment : TimelineItemEventContent {
|
||||
sealed interface TimelineItemEventContentWithAttachment :
|
||||
TimelineItemEventContent,
|
||||
TimelineItemEventMutableContent {
|
||||
val filename: String
|
||||
val caption: String?
|
||||
val formattedCaption: CharSequence?
|
||||
|
|
@ -74,9 +81,7 @@ fun TimelineItemEventContent.canReact(): Boolean =
|
|||
/**
|
||||
* Whether the event content has been edited.
|
||||
*/
|
||||
fun TimelineItemEventContent.isEdited(): Boolean =
|
||||
when (this) {
|
||||
is TimelineItemTextBasedContent -> isEdited
|
||||
is TimelineItemPollContent -> isEdited
|
||||
else -> false
|
||||
}
|
||||
fun TimelineItemEventContent.isEdited(): Boolean = when (this) {
|
||||
is TimelineItemEventMutableContent -> isEdited
|
||||
else -> false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ data class TimelineItemFileContent(
|
|||
override val filename: String,
|
||||
override val caption: String?,
|
||||
override val formattedCaption: CharSequence?,
|
||||
override val isEdited: Boolean,
|
||||
val fileSource: MediaSource,
|
||||
val thumbnailSource: MediaSource?,
|
||||
val formattedFileSize: String,
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ fun aTimelineItemFileContent(
|
|||
filename = fileName,
|
||||
caption = null,
|
||||
formattedCaption = null,
|
||||
isEdited = false,
|
||||
thumbnailSource = null,
|
||||
fileSource = MediaSource(url = ""),
|
||||
mimeType = MimeTypes.Pdf,
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ data class TimelineItemImageContent(
|
|||
override val filename: String,
|
||||
override val caption: String?,
|
||||
override val formattedCaption: CharSequence?,
|
||||
override val isEdited: Boolean,
|
||||
val mediaSource: MediaSource,
|
||||
val thumbnailSource: MediaSource?,
|
||||
val formattedFileSize: String,
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ fun aTimelineItemImageContent(
|
|||
filename = filename,
|
||||
caption = caption,
|
||||
formattedCaption = null,
|
||||
isEdited = false,
|
||||
mediaSource = MediaSource(""),
|
||||
thumbnailSource = null,
|
||||
mimeType = MimeTypes.IMAGE_JPEG,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ data class TimelineItemPollContent(
|
|||
val answerItems: List<PollAnswerItem>,
|
||||
val pollKind: PollKind,
|
||||
val isEnded: Boolean,
|
||||
val isEdited: Boolean
|
||||
) : TimelineItemEventContent {
|
||||
override val isEdited: Boolean,
|
||||
) : TimelineItemEventContent,
|
||||
TimelineItemEventMutableContent {
|
||||
override val type: String = "TimelineItemPollContent"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ data class TimelineItemStickerContent(
|
|||
override val filename: String,
|
||||
override val caption: String?,
|
||||
override val formattedCaption: CharSequence?,
|
||||
override val isEdited: Boolean,
|
||||
val mediaSource: MediaSource,
|
||||
val thumbnailSource: MediaSource?,
|
||||
val formattedFileSize: String,
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ fun aTimelineItemStickerContent(
|
|||
filename = "a sticker.gif",
|
||||
caption = "a body",
|
||||
formattedCaption = null,
|
||||
isEdited = false,
|
||||
mediaSource = MediaSource(""),
|
||||
thumbnailSource = null,
|
||||
mimeType = MimeTypes.IMAGE_JPEG,
|
||||
|
|
|
|||
|
|
@ -14,7 +14,9 @@ import org.jsoup.nodes.Document
|
|||
* Represents a text based content of a timeline item event (a message, a notice, an emote event...).
|
||||
*/
|
||||
@Immutable
|
||||
sealed interface TimelineItemTextBasedContent : TimelineItemEventContent {
|
||||
sealed interface TimelineItemTextBasedContent :
|
||||
TimelineItemEventContent,
|
||||
TimelineItemEventMutableContent {
|
||||
/** The raw body of the event, in Markdown format. */
|
||||
val body: String
|
||||
|
||||
|
|
@ -30,9 +32,6 @@ sealed interface TimelineItemTextBasedContent : TimelineItemEventContent {
|
|||
/** The plain text version of the event body. This is the Markdown version without actual Markdown formatting. */
|
||||
val plainText: String
|
||||
|
||||
/** Whether the event has been edited. */
|
||||
val isEdited: Boolean
|
||||
|
||||
/** The raw HTML body of the event. */
|
||||
val htmlBody: String?
|
||||
get() = htmlDocument?.body()?.html()
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ data class TimelineItemVideoContent(
|
|||
override val filename: String,
|
||||
override val caption: String?,
|
||||
override val formattedCaption: CharSequence?,
|
||||
override val isEdited: Boolean,
|
||||
val duration: Duration,
|
||||
val videoSource: MediaSource,
|
||||
val thumbnailSource: MediaSource?,
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ fun aTimelineItemVideoContent(
|
|||
filename = "Video.mp4",
|
||||
caption = null,
|
||||
formattedCaption = null,
|
||||
isEdited = false,
|
||||
thumbnailSource = null,
|
||||
blurHash = blurhash,
|
||||
aspectRatio = aspectRatio,
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ data class TimelineItemVoiceContent(
|
|||
override val filename: String,
|
||||
override val caption: String?,
|
||||
override val formattedCaption: CharSequence?,
|
||||
override val isEdited: Boolean,
|
||||
val duration: Duration,
|
||||
val mediaSource: MediaSource,
|
||||
val mimeType: String,
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ fun aTimelineItemVoiceContent(
|
|||
filename = filename,
|
||||
caption = caption,
|
||||
formattedCaption = null,
|
||||
isEdited = false,
|
||||
duration = duration,
|
||||
mediaSource = mediaSource,
|
||||
mimeType = mimeType,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue