mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 15:06:08 +03:00
Notifications: remove notification widgets if the notification is gone.
If a notification is not longer in the list that comes from the server, the notification is removed. That is mainly for the notifications that are created by the announcement application
This commit is contained in:
parent
f587f35ef0
commit
d407aacc4a
1 changed files with 24 additions and 0 deletions
|
@ -273,6 +273,30 @@ void ActivityWidget::slotBuildNotificationDisplay(const ActivityList& list)
|
|||
}
|
||||
}
|
||||
|
||||
// check if we have widgets that have no corresponding activity from
|
||||
// the server any more. Collect them in a list
|
||||
QList<int> strayCats;
|
||||
foreach( auto id, _widgetForNotifId.keys() ) {
|
||||
bool found = false;
|
||||
foreach( auto activity, list ) {
|
||||
if( activity._id == id ) {
|
||||
// found an activity
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( ! found ) {
|
||||
// the activity does not exist any more.
|
||||
strayCats.append(id);
|
||||
}
|
||||
}
|
||||
// .. and now delete all these stray cat widgets.
|
||||
foreach( auto strayCatId, strayCats ) {
|
||||
NotificationWidget *widgetToGo = _widgetForNotifId[strayCatId];
|
||||
widgetToGo->deleteLater();
|
||||
_widgetForNotifId.remove(strayCatId);
|
||||
}
|
||||
|
||||
_ui->_notifyLabel->setHidden( _widgetForNotifId.isEmpty() );
|
||||
_ui->_notifyScroll->setHidden( _widgetForNotifId.isEmpty() );
|
||||
|
||||
|
|
Loading…
Reference in a new issue