Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable-3.9] Remove seen Talk notificatios from Tray window. #5869

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/gui/tray/activitylistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
2 changes: 2 additions & 0 deletions src/gui/tray/activitylistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions src/gui/tray/usermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/gui/tray/usermodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down