fix(ags notif center): make first notif appear correctly

This commit is contained in:
matt1432 2023-11-07 11:09:16 -05:00
parent 80427166f5
commit ee5af67444

View file

@ -22,26 +22,18 @@ const addNotif = (box, notif) => {
} }
}; };
// FIXME: first notif never works
const NotificationList = () => Box({ const NotificationList = () => Box({
vertical: true, vertical: true,
vexpand: true, vexpand: true,
vpack: 'start', vpack: 'start',
binds: [['visible', HasNotifs]], binds: [['visible', HasNotifs]],
setup: box => {
// Get cached notifications
const id = Notifications.connect('changed', () => {
Notifications.notifications.forEach(notif => {
addNotif(box, notif);
});
Notifications.disconnect(id);
});
},
connections: [ connections: [
[Notifications, (box, id) => { [Notifications, (box, id) => {
if (!id) // Handle cached notifs
return; if (box.children.length == 0)
Notifications.notifications.forEach(n => addNotif(box, n));
else if (id)
addNotif(box, Notifications.getNotification(id)); addNotif(box, Notifications.getNotification(id));
}, 'notified'], }, 'notified'],