From 86251ff2e3b229a9aa0858dfa72e7c3baf438bab Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Fri, 1 Feb 2019 14:39:59 +0100 Subject: [PATCH] Do not display dismissed notifications Signed-off-by: Roeland Jago Douma --- src/gui/activitylistmodel.cpp | 6 ++++++ src/gui/activitylistmodel.h | 1 + src/gui/activitywidget.cpp | 14 ++++++-------- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/gui/activitylistmodel.cpp b/src/gui/activitylistmodel.cpp index d74e8597b..5b084784b 100644 --- a/src/gui/activitylistmodel.cpp +++ b/src/gui/activitylistmodel.cpp @@ -233,6 +233,12 @@ void ActivityListModel::addNotificationToActivityList(Activity activity) { combineActivityLists(); } +void ActivityListModel::clearNotifications() { + qCInfo(lcActivity) << "Clear the notifications"; + _notificationLists.clear(); + combineActivityLists(); +} + void ActivityListModel::removeActivityFromActivityList(int row) { Activity activity = _finalList.at(row); removeActivityFromActivityList(activity); diff --git a/src/gui/activitylistmodel.h b/src/gui/activitylistmodel.h index 0c7606a0c..2bffabca1 100644 --- a/src/gui/activitylistmodel.h +++ b/src/gui/activitylistmodel.h @@ -49,6 +49,7 @@ public: ActivityList activityList() { return _finalList; } ActivityList errorsList() { return _notificationErrorsLists; } void addNotificationToActivityList(Activity activity); + void clearNotifications(); void addErrorToActivityList(Activity activity); void addSyncFileItemToActivityList(Activity activity); void removeActivityFromActivityList(int row); diff --git a/src/gui/activitywidget.cpp b/src/gui/activitywidget.cpp index 6a58bbd22..f1cf76d03 100644 --- a/src/gui/activitywidget.cpp +++ b/src/gui/activitywidget.cpp @@ -430,20 +430,17 @@ void ActivityWidget::slotOpenFile(QModelIndex indx) // collected. void ActivityWidget::slotBuildNotificationDisplay(const ActivityList &list) { - QString listAccountName; - // Whether a new notification was added to the list bool newNotificationShown = false; + _model->clearNotifications(); + foreach (auto activity, list) { if (_blacklistedNotifications.contains(activity)) { qCInfo(lcActivity) << "Activity in blacklist, skip"; continue; } - // remember the list account name for the strayCat handling below. - listAccountName = activity._accName; - // handle gui logs. In order to NOT annoy the user with every fetching of the // notifications the notification id is stored in a Set. Only if an id // is not in the set, it qualifies for guiLog. @@ -468,14 +465,15 @@ void ActivityWidget::slotBuildNotificationDisplay(const ActivityList &list) emit guiLog(activity._subject, activity._accName); } } - - _model->addNotificationToActivityList(activity); } + + _model->addNotificationToActivityList(activity); } // restart the gui log timer now that we show a new notification - if(newNotificationShown) + if(newNotificationShown) { _guiLogTimer.start(); + } } void ActivityWidget::slotSendNotificationRequest(const QString &accountName, const QString &link, const QByteArray &verb, int row) -- 2.30.2