ags(notifications): more advanced notification body truncating

This commit is contained in:
retrozinndev
2025-04-12 16:42:21 -03:00
parent 735d867564
commit ec623a2371
+5 -1
View File
@@ -23,6 +23,10 @@ export function NotificationWidget(notification: AstalNotifd.Notification|number
AstalNotifd.get_default().get_notification(notification) AstalNotifd.get_default().get_notification(notification)
: notification; : notification;
const body: string = notification.body.split(' ').map(strPart =>
strPart.length >= 25 ? `${strPart.substring(0, 22)}...`
: strPart).join(' ');
return new Widget.EventBox({ return new Widget.EventBox({
onClick: () => { onClick: () => {
if(notification instanceof AstalNotifd.Notification) { if(notification instanceof AstalNotifd.Notification) {
@@ -118,7 +122,7 @@ export function NotificationWidget(notification: AstalNotifd.Notification|number
xalign: 0, xalign: 0,
truncate: false, truncate: false,
wrap: true, wrap: true,
label: notification.body.replace(/\&/g, "&") label: body.replace(/\&/g, "&")
} as Widget.LabelProps) } as Widget.LabelProps)
] ]
} as Widget.BoxProps) } as Widget.BoxProps)