diff --git a/src/notifications/Manager.cpp b/src/notifications/Manager.cpp
index 501bfb3f..6033cc6d 100644
--- a/src/notifications/Manager.cpp
+++ b/src/notifications/Manager.cpp
@@ -7,6 +7,7 @@
#include "Cache.h"
#include "EventAccessors.h"
+#include "Logging.h"
#include "Utils.h"
QString
@@ -33,3 +34,24 @@ NotificationsManager::getMessageTemplate(const mtx::responses::Notification ¬
return QStringLiteral("%1: %2").arg(sender);
}
}
+
+void
+NotificationsManager::removeNotifications(const QString &roomId,
+ const std::vector<QString> &eventIds)
+{
+ std::string room_id = roomId.toStdString();
+
+ std::uint64_t markerPos = 0;
+ for (const auto &e : eventIds) {
+ markerPos = std::max(markerPos, cache::getEventIndex(room_id, e.toStdString()).value_or(0));
+ }
+
+ for (const auto &[roomId, eventId] : this->notificationIds) {
+ if (roomId != roomId)
+ continue;
+ auto idx = cache::getEventIndex(room_id, eventId.toStdString());
+ if (!idx || markerPos >= idx) {
+ removeNotification(roomId, eventId);
+ }
+ }
+}
diff --git a/src/notifications/Manager.h b/src/notifications/Manager.h
index f3b1fe30..05f06dcf 100644
--- a/src/notifications/Manager.h
+++ b/src/notifications/Manager.h
@@ -36,6 +36,8 @@ public:
void postNotification(const mtx::responses::Notification ¬ification, const QImage &icon);
+ void removeNotification(const QString &roomId, const QString &eventId);
+
signals:
void notificationClicked(const QString roomId, const QString eventId);
void sendNotificationReply(const QString roomId, const QString eventId, const QString body);
@@ -46,7 +48,7 @@ signals:
const QImage &icon);
public slots:
- void removeNotification(const QString &roomId, const QString &eventId);
+ void removeNotifications(const QString &roomId, const std::vector<QString> &eventId);
#if defined(NHEKO_DBUS_SYS)
public:
@@ -62,9 +64,6 @@ private:
const QImage &icon);
void closeNotification(uint id);
- // notification ID to (room ID, event ID)
- QMap<uint, roomEventId> notificationIds;
-
const bool hasMarkup_;
const bool hasImages_;
#endif
@@ -96,6 +95,10 @@ private slots:
private:
QString getMessageTemplate(const mtx::responses::Notification ¬ification);
+
+ // notification ID to (room ID, event ID)
+ // Only populated on Linux atm
+ QMap<uint, roomEventId> notificationIds;
};
#if defined(NHEKO_DBUS_SYS)
|