mirror of
https://github.com/edu4rdshl/gnome-shell.git
synced 2026-07-17 23:24:51 +00:00
GtkNotificationDaemon: Improve notification construction
Instead of setting properties after GtkNotificationDaemonNotification construction, pass properties directly to constructor chain up.
This commit is contained in:
parent
d3213c013f
commit
6cf4f49919
1 changed files with 15 additions and 23 deletions
|
|
@ -405,10 +405,6 @@ const PRIORITY_URGENCY_MAP = {
|
|||
const GtkNotificationDaemonNotification = GObject.registerClass(
|
||||
class GtkNotificationDaemonNotification extends MessageTray.Notification {
|
||||
constructor(source, id, notification) {
|
||||
super({source});
|
||||
this._serialized = GLib.Variant.new('a{sv}', notification);
|
||||
this.id = id;
|
||||
|
||||
const {
|
||||
title,
|
||||
body,
|
||||
|
|
@ -421,16 +417,19 @@ class GtkNotificationDaemonNotification extends MessageTray.Notification {
|
|||
timestamp: time,
|
||||
} = notification;
|
||||
|
||||
if (priority) {
|
||||
let urgency = PRIORITY_URGENCY_MAP[priority.unpack()];
|
||||
this.urgency = urgency !== undefined ? urgency : MessageTray.Urgency.NORMAL;
|
||||
} else if (urgent) {
|
||||
this.urgency = urgent.unpack()
|
||||
? MessageTray.Urgency.CRITICAL
|
||||
: MessageTray.Urgency.NORMAL;
|
||||
} else {
|
||||
this.urgency = MessageTray.Urgency.NORMAL;
|
||||
}
|
||||
const urgency = PRIORITY_URGENCY_MAP[priority?.unpack()] ??
|
||||
urgent?.unpack() ? MessageTray.Urgency.CRITICAL : MessageTray.Urgency.NORMAL;
|
||||
|
||||
super({
|
||||
source,
|
||||
title: title.unpack(),
|
||||
body: body?.unpack(),
|
||||
gicon: gicon
|
||||
? Gio.icon_deserialize(gicon) : null,
|
||||
datetime: time
|
||||
? GLib.DateTime.new_from_unix_local(time.unpack()) : null,
|
||||
urgency,
|
||||
});
|
||||
|
||||
if (buttons) {
|
||||
buttons.deepUnpack().forEach(button => {
|
||||
|
|
@ -440,17 +439,10 @@ class GtkNotificationDaemonNotification extends MessageTray.Notification {
|
|||
});
|
||||
}
|
||||
|
||||
this._serialized = GLib.Variant.new('a{sv}', notification);
|
||||
this.id = id;
|
||||
this._defaultAction = defaultAction?.unpack();
|
||||
this._defaultActionTarget = defaultActionTarget;
|
||||
|
||||
this.set({
|
||||
title: title.unpack(),
|
||||
body: body?.unpack(),
|
||||
gicon: gicon
|
||||
? Gio.icon_deserialize(gicon) : null,
|
||||
datetime: time
|
||||
? GLib.DateTime.new_from_unix_local(time.unpack()) : null,
|
||||
});
|
||||
}
|
||||
|
||||
_activateAction(actionId, target) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue