Use <em></em> for m.emote messages
This commit is contained in:
parent
7a6816a9f6
commit
e88cfa1b20
@ -310,27 +310,36 @@ TimelineItem::TimelineItem(mtx::events::MessageType ty,
|
|||||||
auto displayName = Cache::displayName(room_id_, userid);
|
auto displayName = Cache::displayName(room_id_, userid);
|
||||||
auto timestamp = QDateTime::currentDateTime();
|
auto timestamp = QDateTime::currentDateTime();
|
||||||
|
|
||||||
|
// Generate the html body to rendered.
|
||||||
|
auto formatted_body = utils::markdownToHtml(body);
|
||||||
|
|
||||||
|
// Extract the plain text version for the sidebar.
|
||||||
|
body = QString::fromStdString(utils::stripHtml(formatted_body));
|
||||||
|
|
||||||
if (ty == mtx::events::MessageType::Emote) {
|
if (ty == mtx::events::MessageType::Emote) {
|
||||||
body = QString("%1 %2").arg(displayName).arg(body);
|
formatted_body = QString("<em>%1</em>").arg(formatted_body);
|
||||||
descriptionMsg_ = {"", userid, body, utils::descriptiveTime(timestamp), timestamp};
|
descriptionMsg_ = {"",
|
||||||
|
userid,
|
||||||
|
QString("* %1 %2").arg(displayName).arg(body),
|
||||||
|
utils::descriptiveTime(timestamp),
|
||||||
|
timestamp};
|
||||||
} else {
|
} else {
|
||||||
descriptionMsg_ = {
|
descriptionMsg_ = {
|
||||||
"You: ", userid, body, utils::descriptiveTime(timestamp), timestamp};
|
"You: ", userid, body, utils::descriptiveTime(timestamp), timestamp};
|
||||||
}
|
}
|
||||||
|
|
||||||
body = utils::markdownToHtml(body);
|
formatted_body = utils::linkifyMessage(formatted_body);
|
||||||
body = utils::linkifyMessage(body);
|
|
||||||
|
|
||||||
generateTimestamp(timestamp);
|
generateTimestamp(timestamp);
|
||||||
|
|
||||||
if (withSender) {
|
if (withSender) {
|
||||||
generateBody(userid, displayName, body);
|
generateBody(userid, displayName, formatted_body);
|
||||||
setupAvatarLayout(displayName);
|
setupAvatarLayout(displayName);
|
||||||
|
|
||||||
AvatarProvider::resolve(
|
AvatarProvider::resolve(
|
||||||
room_id_, userid, this, [this](const QImage &img) { setUserAvatar(img); });
|
room_id_, userid, this, [this](const QImage &img) { setUserAvatar(img); });
|
||||||
} else {
|
} else {
|
||||||
generateBody(body);
|
generateBody(formatted_body);
|
||||||
setupSimpleLayout();
|
setupSimpleLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -533,9 +542,13 @@ TimelineItem::TimelineItem(const mtx::events::RoomEvent<mtx::events::msg::Emote>
|
|||||||
|
|
||||||
auto timestamp = QDateTime::fromMSecsSinceEpoch(event.origin_server_ts);
|
auto timestamp = QDateTime::fromMSecsSinceEpoch(event.origin_server_ts);
|
||||||
auto displayName = Cache::displayName(room_id_, sender);
|
auto displayName = Cache::displayName(room_id_, sender);
|
||||||
auto emoteMsg = QString("%1 %2").arg(displayName).arg(formatted_body);
|
formatted_body = QString("<em>%1</em>").arg(formatted_body);
|
||||||
|
|
||||||
descriptionMsg_ = {"", sender, emoteMsg, utils::descriptiveTime(timestamp), timestamp};
|
descriptionMsg_ = {"",
|
||||||
|
sender,
|
||||||
|
QString("* %1 %2").arg(displayName).arg(body),
|
||||||
|
utils::descriptiveTime(timestamp),
|
||||||
|
timestamp};
|
||||||
|
|
||||||
generateTimestamp(timestamp);
|
generateTimestamp(timestamp);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user