Commit ee822faf authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

[Notifications] Always transfer state from notification to be replaced

Also keep `created()` with the original notification.

As per spec a notification must be replaced atomically with no visual cues.
Transfer over properties that might cause this, such as unread showing the bell again.
parent 3b836193
......@@ -103,16 +103,14 @@ void AbstractNotificationsModel::Private::onNotificationReplaced(uint replacedId
Notification newNotification(notification);
// Resident notifications are expected to be updateable in the history
// transfer a few flags over to new notification so it doesn't plop back up
if (newNotification.resident()) {
const Notification &oldNotification = notifications.at(row);
if (oldNotification.resident()) {
newNotification.setExpired(oldNotification.expired());
newNotification.setDismissed(oldNotification.dismissed());
newNotification.setRead(oldNotification.read());
}
}
const Notification &oldNotification = notifications.at(row);
// As per spec a notification must be replaced atomically with no visual cues.
// Transfer over properties that might cause this, such as unread showing the bell again,
// or created() which should indicate the original date, whereas updated() is when it was last updated
newNotification.setCreated(oldNotification.created());
newNotification.setExpired(oldNotification.expired());
newNotification.setDismissed(oldNotification.dismissed());
newNotification.setRead(oldNotification.read());
notifications[row] = newNotification;
const QModelIndex idx = q->index(row, 0);
......
......@@ -490,6 +490,11 @@ QDateTime Notification::created() const
return d->created;
}
void Notification::setCreated(const QDateTime &created)
{
d->created = created;
}
QDateTime Notification::updated() const
{
return d->updated;
......
......@@ -55,8 +55,11 @@ public:
QString dBusService() const;
void setDBusService(const QString &dBusService);
// Creation time of the original notification
QDateTime created() const;
void setCreated(const QDateTime &created);
// Last time it was updated, or invalid if it never was
QDateTime updated() const;
void resetUpdated();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment