From fd58ebd5b3151d1bb8b4eb812392be35760d5c1f Mon Sep 17 00:00:00 2001 From: retrozinndev Date: Sat, 9 Aug 2025 23:39:34 -0300 Subject: [PATCH] :boom: fix(widget/notification): actions is null --- src/widget/Notification.tsx | 38 ++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/widget/Notification.tsx b/src/widget/Notification.tsx index 33d5a04..9f64631 100644 --- a/src/widget/Notification.tsx +++ b/src/widget/Notification.tsx @@ -2,13 +2,13 @@ import { Gdk, Gtk } from "ags/gtk4"; import { Separator } from "./Separator"; import { HistoryNotification, Notifications } from "../scripts/notifications"; import { getAppIcon, getSymbolicIcon } from "../scripts/apps"; +import { escapeUnintendedMarkup, pathToURI } from "../scripts/utils"; import { onCleanup } from "ags"; +import GObject from "ags/gobject"; import AstalNotifd from "gi://AstalNotifd"; import Pango from "gi://Pango?version=1.0"; import GLib from "gi://GLib?version=2.0"; -import GObject from "gi://GObject?version=2.0"; -import { escapeUnintendedMarkup, pathToURI } from "../scripts/utils"; function getNotificationImage(notif: AstalNotifd.Notification|HistoryNotification): (string|undefined) { @@ -32,6 +32,12 @@ export function NotificationWidget({ notification, actionClicked, holdOnHover, s AstalNotifd.get_default().get_notification(notification) : notification; + const actions: Array|undefined = (notification instanceof AstalNotifd.Notification) ? + notification.actions?.filter(a => + a.id.toLowerCase() !== "view" && a.label.toLowerCase() != "view" + ) + : undefined; + const conns: Map> = new Map(); onCleanup(() => @@ -105,20 +111,18 @@ export function NotificationWidget({ notification, actionClicked, holdOnHover, s - action.label.toLowerCase() !== "view").length > 0) - }> - { - (notification instanceof AstalNotifd.Notification) && - notification.actions.filter(a => a.label.toLowerCase() !== "view").map(action => - { - notification.invoke(action.id); - actionClose?.(notification); - }} - />) - } - + {(notification instanceof AstalNotifd.Notification) && actions && actions.length > 0 && + + { + actions.map(action => + { + notification.invoke(action.id); + actionClose?.(notification); + }} + />) + } + + } as Gtk.Widget; }