diff --git a/src/gui/tray/activitylistmodel.cpp b/src/gui/tray/activitylistmodel.cpp index 6dddc66124c0..1125a316743d 100644 --- a/src/gui/tray/activitylistmodel.cpp +++ b/src/gui/tray/activitylistmodel.cpp @@ -640,6 +640,15 @@ void ActivityListModel::removeActivityFromActivityList(const Activity &activity) } } +void ActivityListModel::checkAndRemoveSeenActivities(const OCC::ActivityList &newActivities) +{ + for (const auto &activity : _finalList) { + if (activity._objectType == QStringLiteral("chat") && !newActivities.contains(activity)) { + removeActivityFromActivityList(activity); + } + } +} + void ActivityListModel::slotTriggerDefaultAction(const int activityIndex) { if (activityIndex < 0 || activityIndex >= _finalList.size()) { diff --git a/src/gui/tray/activitylistmodel.h b/src/gui/tray/activitylistmodel.h index ba75bb5c6165..b0a36e2eed67 100644 --- a/src/gui/tray/activitylistmodel.h +++ b/src/gui/tray/activitylistmodel.h @@ -134,6 +134,8 @@ public slots: void removeActivityFromActivityList(int row); void removeActivityFromActivityList(const OCC::Activity &activity); + void checkAndRemoveSeenActivities(const OCC::ActivityList &newActivities); + void setAccountState(OCC::AccountState *state); void setReplyMessageSent(const int activityIndex, const QString &message); void setCurrentItem(const int currentItem); diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp index bf4b0e27942a..6441a2f0ad62 100644 --- a/src/gui/tray/usermodel.cpp +++ b/src/gui/tray/usermodel.cpp @@ -221,13 +221,21 @@ void User::slotBuildNotificationDisplay(const ActivityList &list) return; } + auto chatNotificationsReceivedCount = 0; + for(const auto &activity : qAsConst(toNotifyList)) { if (activity._objectType == QStringLiteral("chat")) { + ++chatNotificationsReceivedCount; showDesktopTalkNotification(activity); } else { showDesktopNotification(activity); } } + + if (chatNotificationsReceivedCount < _lastChatNotificationsReceivedCount) { + _activityModel->checkAndRemoveSeenActivities(toNotifyList); + } + _lastChatNotificationsReceivedCount = chatNotificationsReceivedCount; } void User::slotBuildIncomingCallDialogs(const ActivityList &list) diff --git a/src/gui/tray/usermodel.h b/src/gui/tray/usermodel.h index 353035fb68ff..e39b02ee9e12 100644 --- a/src/gui/tray/usermodel.h +++ b/src/gui/tray/usermodel.h @@ -182,6 +182,8 @@ private slots: // number of currently running notification requests. If non zero, // no query for notifications is started. int _notificationRequestsRunning = 0; + + int _lastChatNotificationsReceivedCount = 0; }; class UserModel : public QAbstractListModel