messageTray: Automatically update Notification's datetime on property changes
Setting the `datetime` property whenever a notification is updated is tedious and error-prone. Therefore, whenever properties, other then `acknowledged` and `datetime`, of a notification change update the `datetime` property to the current time. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3173>
This commit is contained in:
parent
d54219c098
commit
9ac4c7da53
@ -358,6 +358,25 @@ export class Notification extends GObject.Object {
|
||||
|
||||
if (!this.datetime)
|
||||
this.datetime = GLib.DateTime.new_now_local();
|
||||
|
||||
// Automatically update the datetime property when the notification
|
||||
// is updated.
|
||||
this.connect('notify', (o, pspec) => {
|
||||
if (pspec.name === 'acknowledged') {
|
||||
// Don't update datetime property
|
||||
} else if (pspec.name === 'datetime') {
|
||||
if (this._updateDatetimeId)
|
||||
GLib.source_remove(this._updateDatetimeId);
|
||||
delete this._updateDatetimeId;
|
||||
} else if (!this._updateDatetimeId) {
|
||||
this._updateDatetimeId =
|
||||
GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
|
||||
delete this._updateDatetimeId;
|
||||
this.datetime = GLib.DateTime.new_now_local();
|
||||
return GLib.SOURCE_REMOVE;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// update:
|
||||
|
Loading…
x
Reference in New Issue
Block a user