mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
Add regex to remove replies in notifications
This commit is contained in:
parent
c693d54598
commit
37acdad928
3 changed files with 16 additions and 5 deletions
|
@ -7,6 +7,7 @@
|
||||||
#include <QDBusPendingReply>
|
#include <QDBusPendingReply>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
|
#include <QRegularExpression>
|
||||||
#include <QTextDocumentFragment>
|
#include <QTextDocumentFragment>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
@ -176,9 +177,12 @@ NotificationsManager::formatNotification(const mtx::events::collections::Timelin
|
||||||
.replace("<em>", "<i>")
|
.replace("<em>", "<i>")
|
||||||
.replace("</em>", "</i>")
|
.replace("</em>", "</i>")
|
||||||
.replace("<strong>", "<b>")
|
.replace("<strong>", "<b>")
|
||||||
.replace("</strong>", "</b>");
|
.replace("</strong>", "</b>")
|
||||||
|
.replace(QRegularExpression("(<mx-reply>.+\\<\\/mx-reply\\>)"), "");
|
||||||
|
|
||||||
return QTextDocumentFragment::fromHtml(mtx::accessors::formattedBodyWithFallback(e))
|
return QTextDocumentFragment::fromHtml(
|
||||||
|
mtx::accessors::formattedBodyWithFallback(e).replace(
|
||||||
|
QRegularExpression("(<mx-reply>.+\\<\\/mx-reply\\>)"), ""))
|
||||||
.toPlainText();
|
.toPlainText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "Manager.h"
|
#include "Manager.h"
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
#include <QTextDocumentFragment>
|
#include <QTextDocumentFragment>
|
||||||
|
|
||||||
#include "EventAccessors.h"
|
#include "EventAccessors.h"
|
||||||
|
@ -8,5 +9,8 @@
|
||||||
QString
|
QString
|
||||||
NotificationsManager::formatNotification(const mtx::events::collections::TimelineEvents &e)
|
NotificationsManager::formatNotification(const mtx::events::collections::TimelineEvents &e)
|
||||||
{
|
{
|
||||||
return QTextDocumentFragment::fromHtml(mtx::accessors::formattedBodyWithFallback(e)).toPlainText();
|
return QTextDocumentFragment::fromHtml(
|
||||||
|
mtx::accessors::formattedBodyWithFallback(e).replace(
|
||||||
|
QRegularExpression("(<mx-reply>.+\\<\\/mx-reply\\>)"), ""))
|
||||||
|
.toPlainText();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "notifications/Manager.h"
|
#include "notifications/Manager.h"
|
||||||
#include "wintoastlib.h"
|
#include "wintoastlib.h"
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
#include <QTextDocumentFragment>
|
#include <QTextDocumentFragment>
|
||||||
|
|
||||||
#include "EventAccessors.h"
|
#include "EventAccessors.h"
|
||||||
|
@ -80,6 +81,8 @@ NotificationsManager::removeNotification(const QString &, const QString &)
|
||||||
QString
|
QString
|
||||||
NotificationsManager::formatNotification(const mtx::events::collections::TimelineEvents &e)
|
NotificationsManager::formatNotification(const mtx::events::collections::TimelineEvents &e)
|
||||||
{
|
{
|
||||||
return QTextDocumentFragment::fromHtml(mtx::accessors::formattedBodyWithFallback(e)).toPlainText();
|
return QTextDocumentFragment::fromHtml(
|
||||||
|
mtx::accessors::formattedBodyWithFallback(e).replace(
|
||||||
|
QRegularExpression("(<mx-reply>.+\\<\\/mx-reply\\>)"), ""))
|
||||||
|
.toPlainText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue