Improve visualization of replies to non-message events
This commit is contained in:
committed by
Tobias Fella
parent
4c638a740e
commit
207a7876b6
@@ -70,9 +70,11 @@ public:
|
||||
*
|
||||
* @param event the event to return a type for.
|
||||
*
|
||||
* @param isInReply whether this event is to be treated like a replied-to event (i.e., a basic text fallback should be shown if no other type is used)
|
||||
*
|
||||
* @sa Type
|
||||
*/
|
||||
static Type typeForEvent(const Quotient::RoomEvent &event)
|
||||
static Type typeForEvent(const Quotient::RoomEvent &event, bool isInReply = false)
|
||||
{
|
||||
using namespace Quotient;
|
||||
|
||||
@@ -103,7 +105,8 @@ public:
|
||||
if (event.matrixType() == u"org.matrix.msc3672.beacon_info"_s) {
|
||||
return MessageComponentType::LiveLocation;
|
||||
}
|
||||
return MessageComponentType::Other;
|
||||
// In the (unlikely) case that this is a reply to a state event, we do want to show something
|
||||
return isInReply ? MessageComponentType::Text : MessageComponentType::Other;
|
||||
}
|
||||
if (is<const EncryptedEvent>(event)) {
|
||||
return MessageComponentType::Encrypted;
|
||||
@@ -116,7 +119,8 @@ public:
|
||||
return MessageComponentType::Poll;
|
||||
}
|
||||
|
||||
return MessageComponentType::Other;
|
||||
// In the (unlikely) case that this is a reply to an unusual event, we do want to show something
|
||||
return isInReply ? MessageComponentType::Text : MessageComponentType::Other;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -451,6 +451,9 @@ QString EventHandler::getBody(const NeoChatRoom *room, const Quotient::RoomEvent
|
||||
[](const EncryptedEvent &) {
|
||||
return i18nc("@info In room list", "Encrypted event");
|
||||
},
|
||||
[](const ReactionEvent &e) {
|
||||
return i18nc("[user] reacted with <emoji>", "reacted with %1", e.key());
|
||||
},
|
||||
i18n("Unknown event"));
|
||||
}
|
||||
|
||||
|
||||
@@ -590,7 +590,7 @@ TextHandler::textComponents(QString string, Qt::TextFormat inputFormat, const Ne
|
||||
string = string.trimmed();
|
||||
|
||||
if (event != nullptr && room != nullptr) {
|
||||
if (auto e = eventCast<const Quotient::RoomMessageEvent>(event); e->msgtype() == Quotient::MessageEventType::Emote && components.size() == 1) {
|
||||
if (auto e = eventCast<const Quotient::RoomMessageEvent>(event); e && e->msgtype() == Quotient::MessageEventType::Emote && components.size() == 1) {
|
||||
if (components[0].type == MessageComponentType::Text) {
|
||||
components[0].content = emoteString(room, event) + components[0].content;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user