forked from Shinonome/dots-hyprland
FIX SPAMMING NOTIF ERRORS FINALLY OMGGGGGGGGGG (btw #215)
This commit is contained in:
@@ -20,6 +20,10 @@ function guessMessageType(summary) {
|
|||||||
return 'chat';
|
return 'chat';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function exists(widget) {
|
||||||
|
return widget !== null;
|
||||||
|
}
|
||||||
|
|
||||||
const NotificationIcon = (notifObject) => {
|
const NotificationIcon = (notifObject) => {
|
||||||
// { appEntry, appIcon, image }, urgency = 'normal'
|
// { appEntry, appIcon, image }, urgency = 'normal'
|
||||||
if (notifObject.image) {
|
if (notifObject.image) {
|
||||||
@@ -71,9 +75,9 @@ const NotificationIcon = (notifObject) => {
|
|||||||
export default ({
|
export default ({
|
||||||
notifObject,
|
notifObject,
|
||||||
isPopup = false,
|
isPopup = false,
|
||||||
popupTimeout = 3000,
|
|
||||||
props = {},
|
props = {},
|
||||||
} = {}) => {
|
} = {}) => {
|
||||||
|
const popupTimeout = notifObject.urgency == 'critical' ? 8000 : 3000;
|
||||||
const command = (isPopup ?
|
const command = (isPopup ?
|
||||||
() => notifObject.dismiss() :
|
() => notifObject.dismiss() :
|
||||||
() => notifObject.close()
|
() => notifObject.close()
|
||||||
@@ -82,11 +86,14 @@ export default ({
|
|||||||
widget.sensitive = false;
|
widget.sensitive = false;
|
||||||
notificationBox.setCss(middleClickClose);
|
notificationBox.setCss(middleClickClose);
|
||||||
Utils.timeout(200, () => {
|
Utils.timeout(200, () => {
|
||||||
wholeThing.revealChild = false;
|
if (wholeThing) wholeThing.revealChild = false;
|
||||||
}, wholeThing);
|
}, wholeThing);
|
||||||
Utils.timeout(400, () => {
|
Utils.timeout(400, () => {
|
||||||
command();
|
command();
|
||||||
wholeThing.destroy();
|
if (wholeThing) {
|
||||||
|
wholeThing.destroy();
|
||||||
|
wholeThing = null;
|
||||||
|
}
|
||||||
}, wholeThing);
|
}, wholeThing);
|
||||||
}
|
}
|
||||||
const widget = EventBox({
|
const widget = EventBox({
|
||||||
@@ -111,7 +118,7 @@ export default ({
|
|||||||
wholeThing.attribute.held = true;
|
wholeThing.attribute.held = true;
|
||||||
notificationContent.toggleClassName(`${isPopup ? 'popup-' : ''}notif-clicked-${notifObject.urgency}`, true);
|
notificationContent.toggleClassName(`${isPopup ? 'popup-' : ''}notif-clicked-${notifObject.urgency}`, true);
|
||||||
Utils.timeout(800, () => {
|
Utils.timeout(800, () => {
|
||||||
if (wholeThing.attribute.held) {
|
if (wholeThing?.attribute.held) {
|
||||||
Utils.execAsync(['wl-copy', `${notifObject.body}`])
|
Utils.execAsync(['wl-copy', `${notifObject.body}`])
|
||||||
notifTextSummary.label = notifObject.summary + " (copied)";
|
notifTextSummary.label = notifObject.summary + " (copied)";
|
||||||
Utils.timeout(3000, () => notifTextSummary.label = notifObject.summary)
|
Utils.timeout(3000, () => notifTextSummary.label = notifObject.summary)
|
||||||
@@ -123,10 +130,10 @@ export default ({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const wholeThing = Revealer({
|
let wholeThing = Revealer({
|
||||||
attribute: {
|
attribute: {
|
||||||
'close': undefined,
|
'close': undefined,
|
||||||
'destroyWithAnims': () => destroyWithAnims,
|
'destroyWithAnims': destroyWithAnims,
|
||||||
'dragging': false,
|
'dragging': false,
|
||||||
'held': false,
|
'held': false,
|
||||||
'hovered': false,
|
'hovered': false,
|
||||||
@@ -137,7 +144,7 @@ export default ({
|
|||||||
transitionDuration: 200,
|
transitionDuration: 200,
|
||||||
child: Box({ // Box to make sure css-based spacing works
|
child: Box({ // Box to make sure css-based spacing works
|
||||||
homogeneous: true,
|
homogeneous: true,
|
||||||
})
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const display = Gdk.Display.get_default();
|
const display = Gdk.Display.get_default();
|
||||||
@@ -400,11 +407,14 @@ export default ({
|
|||||||
widget.sensitive = false;
|
widget.sensitive = false;
|
||||||
}
|
}
|
||||||
Utils.timeout(200, () => {
|
Utils.timeout(200, () => {
|
||||||
wholeThing.revealChild = false
|
if (wholeThing) wholeThing.revealChild = false;
|
||||||
}, wholeThing);
|
}, wholeThing);
|
||||||
Utils.timeout(400, () => {
|
Utils.timeout(400, () => {
|
||||||
command();
|
command();
|
||||||
wholeThing.destroy();
|
if (wholeThing) {
|
||||||
|
wholeThing.destroy();
|
||||||
|
wholeThing = null;
|
||||||
|
}
|
||||||
}, wholeThing);
|
}, wholeThing);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -425,6 +435,17 @@ export default ({
|
|||||||
})
|
})
|
||||||
widget.add(notificationBox);
|
widget.add(notificationBox);
|
||||||
wholeThing.child.children = [widget];
|
wholeThing.child.children = [widget];
|
||||||
|
if (isPopup) Utils.timeout(popupTimeout, () => {
|
||||||
|
if (wholeThing) {
|
||||||
|
wholeThing.revealChild = false;
|
||||||
|
Utils.timeout(200, () => {
|
||||||
|
if (wholeThing) {
|
||||||
|
wholeThing.destroy();
|
||||||
|
wholeThing = null;
|
||||||
|
}
|
||||||
|
command();
|
||||||
|
}, wholeThing);
|
||||||
|
}
|
||||||
|
})
|
||||||
return wholeThing;
|
return wholeThing;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ export default () => Box({
|
|||||||
box.attribute.map.set(id, newNotif);
|
box.attribute.map.set(id, newNotif);
|
||||||
box.pack_end(box.attribute.map.get(id), false, false, 0);
|
box.pack_end(box.attribute.map.get(id), false, false, 0);
|
||||||
box.show_all();
|
box.show_all();
|
||||||
|
|
||||||
// box.children = Array.from(box.attribute.map.values()).reverse();
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup: (self) => self
|
setup: (self) => self
|
||||||
|
|||||||
@@ -85,7 +85,8 @@ export default (props) => {
|
|||||||
self.toggleClassName('notif-listaction-btn-enabled', Notifications.dnd);
|
self.toggleClassName('notif-listaction-btn-enabled', Notifications.dnd);
|
||||||
});
|
});
|
||||||
const clearButton = ListActionButton('clear_all', 'Clear', () => {
|
const clearButton = ListActionButton('clear_all', 'Clear', () => {
|
||||||
notificationList.get_children().forEach(ch => ch.destroy());
|
// Manual destruction is not necessary
|
||||||
|
// since Notifications.clear() sends destroy signals to every notif
|
||||||
Notifications.clear();
|
Notifications.clear();
|
||||||
});
|
});
|
||||||
const listTitle = Box({
|
const listTitle = Box({
|
||||||
|
|||||||
Reference in New Issue
Block a user