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

Bugfix. Remove seen call notifications from the list. #6563

Merged
merged 1 commit into from
Apr 2, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/gui/tray/activitylistmodel.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/gui/tray/activitylistmodel.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/tray/activitylistmodel.cpp

File src/gui/tray/activitylistmodel.cpp does not conform to Custom style guidelines. (lines 691)
* Copyright (C) by Klaas Freitag <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -688,7 +688,9 @@
{
ActivityList activitiesToRemove;
for (const auto &activity : _finalList) {
if (activity._objectType == QStringLiteral("chat") && !newActivities.contains(activity)) {
const auto isTalkActiity = activity._objectType == QStringLiteral("chat") ||
activity._objectType == QStringLiteral("call");
if (isTalkActiity && !newActivities.contains(activity)) {
activitiesToRemove.push_back(activity);
}
}
Expand Down
13 changes: 7 additions & 6 deletions src/gui/tray/usermodel.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "notificationhandler.h"

Check notice on line 1 in src/gui/tray/usermodel.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/tray/usermodel.cpp

File src/gui/tray/usermodel.cpp does not conform to Custom style guidelines. (lines 209)
#include "usermodel.h"

#include "accountmanager.h"
Expand Down Expand Up @@ -119,12 +119,12 @@
!notificationAlreadyShown(notificationId);
}

void User::checkAndRemoveSeenActivities(const ActivityList &list, const int numChatNotificationsReceived)
void User::checkAndRemoveSeenActivities(const ActivityList &list, const int numTalkNotificationsReceived)

Check warning on line 122 in src/gui/tray/usermodel.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/tray/usermodel.cpp:122:41 [bugprone-easily-swappable-parameters]

2 adjacent parameters of 'checkAndRemoveSeenActivities' of similar type are easily swapped by mistake
{
if (numChatNotificationsReceived < _lastChatNotificationsReceivedCount) {
if (numTalkNotificationsReceived < _lastTalkNotificationsReceivedCount) {
_activityModel->checkAndRemoveSeenActivities(list);
}
_lastChatNotificationsReceivedCount = numChatNotificationsReceived;
_lastTalkNotificationsReceivedCount = numTalkNotificationsReceived;
}

void User::showDesktopNotification(const QString &title, const QString &message, const long notificationId)
Expand Down Expand Up @@ -205,10 +205,11 @@

void User::slotBuildNotificationDisplay(const ActivityList &list)
{
const auto chatNotificationsReceivedCount = std::count_if(std::cbegin(list), std::cend(list), [](const auto &activity) {
return activity._objectType == QStringLiteral("chat");
const auto talkNotificationsReceivedCount = std::count_if(std::cbegin(list), std::cend(list), [](const auto &activity) {
return activity._objectType == QStringLiteral("chat") ||
activity._objectType == QStringLiteral("call");
});
checkAndRemoveSeenActivities(list, chatNotificationsReceivedCount);
checkAndRemoveSeenActivities(list, talkNotificationsReceivedCount);

ActivityList toNotifyList;

Expand Down
4 changes: 2 additions & 2 deletions src/gui/tray/usermodel.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef USERMODEL_H
#define USERMODEL_H

#include <QAbstractListModel>

Check failure on line 4 in src/gui/tray/usermodel.h

View workflow job for this annotation

GitHub Actions / build

src/gui/tray/usermodel.h:4:10 [clang-diagnostic-error]

'QAbstractListModel' file not found
#include <QImage>
#include <QDateTime>
#include <QStringList>
Expand Down Expand Up @@ -166,7 +166,7 @@
bool notificationAlreadyShown(const long notificationId);
bool canShowNotification(const long notificationId);

void checkAndRemoveSeenActivities(const ActivityList &list, const int numChatNotificationsReceived);
void checkAndRemoveSeenActivities(const ActivityList &list, const int numTalkNotificationsReceived);

AccountStatePtr _account;
bool _isCurrentUser;
Expand All @@ -188,7 +188,7 @@
// no query for notifications is started.
int _notificationRequestsRunning = 0;

int _lastChatNotificationsReceivedCount = 0;
int _lastTalkNotificationsReceivedCount = 0;

bool _isNotificationFetchRunning = false;
};
Expand Down
Loading