Clean up notification code a bit
This commit is contained in:
parent
95026dcc62
commit
e5d75c814b
16 changed files with 204 additions and 474 deletions
|
|
@ -108,20 +108,11 @@ NotificationsManager::formatNotification(const mtx::responses::Notification ¬
|
|||
cache::displayName(QString::fromStdString(notification.room_id),
|
||||
QString::fromStdString(mtx::accessors::sender(notification.event)));
|
||||
|
||||
const auto messageLeadIn =
|
||||
((mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Emote)
|
||||
? "* " + sender + " "
|
||||
: sender +
|
||||
(utils::isReply(notification.event)
|
||||
? tr(" replied",
|
||||
"Used to denote that this message is a reply to another "
|
||||
"message. Displayed as 'foo replied: message'.")
|
||||
: "") +
|
||||
": ");
|
||||
const auto template_ = getMessageTemplate(notification);
|
||||
if (std::holds_alternative<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(
|
||||
notification.event)) {
|
||||
return template_;
|
||||
}
|
||||
|
||||
return QTextDocumentFragment::fromHtml(
|
||||
mtx::accessors::formattedBodyWithFallback(notification.event)
|
||||
.replace(QRegularExpression("<mx-reply>.+</mx-reply>"), ""))
|
||||
.toPlainText()
|
||||
.prepend(messageLeadIn);
|
||||
return template_.arg(utils::stripReplyFallbacks(notification.event, {}, {}).quoted_body);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue