From e5d75c814b2175dc37beabff3b0421de59a3e93e Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Wed, 17 Mar 2021 19:08:17 +0100 Subject: Clean up notification code a bit --- src/notifications/ManagerWin.cpp | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'src/notifications/ManagerWin.cpp') diff --git a/src/notifications/ManagerWin.cpp b/src/notifications/ManagerWin.cpp index baafb6dc..d37bff67 100644 --- a/src/notifications/ManagerWin.cpp +++ b/src/notifications/ManagerWin.cpp @@ -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'.") - : "") + - ": "); - - return QTextDocumentFragment::fromHtml( - mtx::accessors::formattedBodyWithFallback(notification.event) - .replace(QRegularExpression(".+"), "")) - .toPlainText() - .prepend(messageLeadIn); + const auto template_ = getMessageTemplate(notification); + if (std::holds_alternative>( + notification.event)) { + return template_; + } + + return template_.arg(utils::stripReplyFallbacks(notification.event, {}, {}).quoted_body); } -- cgit 1.5.1