Event Handler

Similar to text handler, pull out the disparate array of functions which format information from an event ready for display in the UI and put in a handler class with a test suite.

requires https://github.com/quotient-im/libQuotient/pull/686
This commit is contained in:
James Graham
2023-09-07 19:02:50 +00:00
parent 597633f824
commit 2c6ab498ac
26 changed files with 2397 additions and 997 deletions

View File

@@ -42,6 +42,11 @@ ColumnLayout {
*/
required property var time
/**
* @brief The timestamp of the message as a string.
*/
required property string timeString
/**
* @brief The message author.
*
@@ -154,13 +159,14 @@ ColumnLayout {
required property var replyAuthor
/**
* @brief The reply content.
*
* This should consist of the following:
* - display - The display text of the reply.
* - type - The delegate type of the reply.
* @brief The delegate type of the message replied to.
*/
required property var reply
required property int replyDelegateType
/**
* @brief The display text of the message replied to.
*/
required property string replyDisplay
/**
* @brief The media info for the reply event.
@@ -206,11 +212,6 @@ ColumnLayout {
*/
required property bool verified
/**
* @brief The mime type of the message's file or media.
*/
required property var mimeType
/**
* @brief The full message source JSON.
*/
@@ -357,7 +358,7 @@ ColumnLayout {
implicitHeight: Math.max(root.showAuthor || root.alwaysShowAuthor ? avatar.implicitHeight : 0, bubble.height)
Component.onCompleted: {
if (root.isReply && root.reply === undefined) {
if (root.isReply && root.replyDelegateType === DelegateType.Other) {
currentRoom.loadReply(root.eventId, root.replyId)
}
}
@@ -478,7 +479,7 @@ ColumnLayout {
QQC2.Label {
id: timeLabel
text: visible ? root.time.toLocaleTimeString(Qt.locale(), Locale.ShortFormat) : ""
text: root.timeString
color: Kirigami.Theme.disabledTextColor
QQC2.ToolTip.visible: hoverHandler.hovered
QQC2.ToolTip.text: root.time.toLocaleString(Qt.locale(), Locale.LongFormat)
@@ -494,13 +495,13 @@ ColumnLayout {
Layout.maximumWidth: contentMaxWidth
active: root.isReply && root.reply
active: root.isReply && root.replyDelegateType !== DelegateType.Other
visible: active
sourceComponent: ReplyComponent {
author: root.replyAuthor
type: root.reply.type
display: root.reply.display
type: root.replyDelegateType
display: root.replyDisplay
mediaInfo: root.replyMediaInfo
contentMaxWidth: bubbleSizeHelper.currentWidth
}
@@ -609,7 +610,6 @@ ColumnLayout {
eventId: root.eventId,
source: root.jsonSource,
file: file,
mimeType: root.mimeType,
progressInfo: root.progressInfo,
plainText: root.plainText,
});