Merge pull request #5851 from nextcloud/feature/remove-seen-talk-notifications

Remove seen Talk notificatios from Tray window.
This commit is contained in:
allexzander 2023-07-06 10:00:30 +02:00 committed by GitHub
commit 4cc1395529
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 0 deletions

View File

@ -689,6 +689,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()) {

View File

@ -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);

View File

@ -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)

View File

@ -182,6 +182,8 @@ private:
// 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