💥 fix(widget/notification): actions is null
This commit is contained in:
+21
-17
@@ -2,13 +2,13 @@ import { Gdk, Gtk } from "ags/gtk4";
|
|||||||
import { Separator } from "./Separator";
|
import { Separator } from "./Separator";
|
||||||
import { HistoryNotification, Notifications } from "../scripts/notifications";
|
import { HistoryNotification, Notifications } from "../scripts/notifications";
|
||||||
import { getAppIcon, getSymbolicIcon } from "../scripts/apps";
|
import { getAppIcon, getSymbolicIcon } from "../scripts/apps";
|
||||||
|
import { escapeUnintendedMarkup, pathToURI } from "../scripts/utils";
|
||||||
import { onCleanup } from "ags";
|
import { onCleanup } from "ags";
|
||||||
|
|
||||||
|
import GObject from "ags/gobject";
|
||||||
import AstalNotifd from "gi://AstalNotifd";
|
import AstalNotifd from "gi://AstalNotifd";
|
||||||
import Pango from "gi://Pango?version=1.0";
|
import Pango from "gi://Pango?version=1.0";
|
||||||
import GLib from "gi://GLib?version=2.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) {
|
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)
|
AstalNotifd.get_default().get_notification(notification)
|
||||||
: notification;
|
: notification;
|
||||||
|
|
||||||
|
const actions: Array<AstalNotifd.Action>|undefined = (notification instanceof AstalNotifd.Notification) ?
|
||||||
|
notification.actions?.filter(a =>
|
||||||
|
a.id.toLowerCase() !== "view" && a.label.toLowerCase() != "view"
|
||||||
|
)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
const conns: Map<GObject.Object, Array<number>> = new Map();
|
const conns: Map<GObject.Object, Array<number>> = new Map();
|
||||||
|
|
||||||
onCleanup(() =>
|
onCleanup(() =>
|
||||||
@@ -105,20 +111,18 @@ export function NotificationWidget({ notification, actionClicked, holdOnHover, s
|
|||||||
</Gtk.Box>
|
</Gtk.Box>
|
||||||
</Gtk.Box>
|
</Gtk.Box>
|
||||||
|
|
||||||
<Gtk.Box class={"actions button-row"} hexpand={true} visible={
|
{(notification instanceof AstalNotifd.Notification) && actions && actions.length > 0 &&
|
||||||
(notification instanceof AstalNotifd.Notification) &&
|
<Gtk.Box class={"actions button-row"} hexpand>
|
||||||
(notification.actions.filter(action => action.label.toLowerCase() !== "view").length > 0)
|
{
|
||||||
}>
|
actions.map(action =>
|
||||||
{
|
<Gtk.Button class={"action"} label={action.label} hexpand
|
||||||
(notification instanceof AstalNotifd.Notification) &&
|
onClicked={(_) => {
|
||||||
notification.actions.filter(a => a.label.toLowerCase() !== "view").map(action =>
|
notification.invoke(action.id);
|
||||||
<Gtk.Button class={"action"} label={action.label}
|
actionClose?.(notification);
|
||||||
hexpand={true} onClicked={(_) => {
|
}}
|
||||||
notification.invoke(action.id);
|
/>)
|
||||||
actionClose?.(notification);
|
}
|
||||||
}}
|
</Gtk.Box>
|
||||||
/>)
|
}
|
||||||
}
|
|
||||||
</Gtk.Box>
|
|
||||||
</Gtk.Box> as Gtk.Widget;
|
</Gtk.Box> as Gtk.Widget;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user