1 files changed, 22 insertions, 0 deletions
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);
+ }
+ }
+}
|