Handle emotes in texthander
This moves the code to add the emote user pill into texthandler removing the now redundant checks from the message delegates.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <QDebug>
|
||||
#include <QUrl>
|
||||
|
||||
#include <events/roommessageevent.h>
|
||||
#include <util.h>
|
||||
|
||||
#include <cmark.h>
|
||||
@@ -134,6 +135,21 @@ QString TextHandler::handleRecieveRichText(Qt::TextFormat inputFormat, const Neo
|
||||
nextTokenType();
|
||||
}
|
||||
|
||||
// If the message is an emote add the user pill to the front of the message.
|
||||
if (event != nullptr) {
|
||||
auto e = eventCast<const Quotient::RoomMessageEvent>(event);
|
||||
if (e->msgtype() == Quotient::MessageEventType::Emote) {
|
||||
auto author = static_cast<NeoChatUser *>(room->user(e->senderId()));
|
||||
QString emoteString = QStringLiteral("* <a href=\"https://matrix.to/#/") + e->senderId() + QStringLiteral("\" style=\"color:")
|
||||
+ author->color().name() + QStringLiteral("\">") + author->displayname(room) + QStringLiteral("</a> ");
|
||||
if (outputString.startsWith(QStringLiteral("<p>"))) {
|
||||
outputString.insert(3, emoteString);
|
||||
} else {
|
||||
outputString.prepend(emoteString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace <del> with <s>
|
||||
* Note: <s> is still not a valid tag for the message from the server. We
|
||||
|
||||
Reference in New Issue
Block a user