fix: add null guards to notifs

This commit is contained in:
2 * r + 2 * t 2026-04-03 17:03:18 +11:00
parent faaae7be44
commit cf8b68be3b
2 changed files with 10 additions and 10 deletions

View file

@ -22,7 +22,7 @@ StyledRect {
radius: Appearance.rounding.small radius: Appearance.rounding.small
color: { color: {
const c = root.modelData.urgency === "critical" ? Colours.palette.m3secondaryContainer : Colours.layer(Colours.palette.m3surfaceContainerHigh, 2); const c = root.modelData?.urgency === "critical" ? Colours.palette.m3secondaryContainer : Colours.layer(Colours.palette.m3surfaceContainerHigh, 2);
return expanded ? c : Qt.alpha(c, 0); return expanded ? c : Qt.alpha(c, 0);
} }
@ -61,8 +61,8 @@ StyledRect {
anchors.left: parent.left anchors.left: parent.left
width: parent.width width: parent.width
text: root.modelData.summary text: root.modelData?.summary ?? ""
color: root.modelData.urgency === "critical" ? Colours.palette.m3onSecondaryContainer : Colours.palette.m3onSurface color: root.modelData?.urgency === "critical" ? Colours.palette.m3onSecondaryContainer : Colours.palette.m3onSurface
elide: Text.ElideRight elide: Text.ElideRight
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
maximumLineCount: 1 maximumLineCount: 1
@ -75,7 +75,7 @@ StyledRect {
anchors.left: parent.left anchors.left: parent.left
visible: false visible: false
text: root.modelData.summary text: root.modelData?.summary ?? ""
} }
WrappedLoader { WrappedLoader {
@ -88,8 +88,8 @@ StyledRect {
anchors.leftMargin: Appearance.spacing.small anchors.leftMargin: Appearance.spacing.small
sourceComponent: StyledText { sourceComponent: StyledText {
text: root.modelData.body.replace(/\n/g, " ") text: (root.modelData?.body ?? "").replace(/\n/g, " ")
color: root.modelData.urgency === "critical" ? Colours.palette.m3secondary : Colours.palette.m3outline color: root.modelData?.urgency === "critical" ? Colours.palette.m3secondary : Colours.palette.m3outline
elide: Text.ElideRight elide: Text.ElideRight
} }
} }
@ -103,7 +103,7 @@ StyledRect {
sourceComponent: StyledText { sourceComponent: StyledText {
animate: true animate: true
text: root.modelData.timeStr text: root.modelData?.timeStr ?? ""
color: Colours.palette.m3outline color: Colours.palette.m3outline
font.pointSize: Appearance.font.size.small font.pointSize: Appearance.font.size.small
} }
@ -138,8 +138,8 @@ StyledRect {
Layout.fillWidth: true Layout.fillWidth: true
textFormat: Text.MarkdownText textFormat: Text.MarkdownText
text: root.modelData.body.replace(/(.)\n(?!\n)/g, "$1\n\n") || qsTr("No body here! :/") text: (root.modelData?.body ?? "").replace(/(.)\n(?!\n)/g, "$1\n\n") || qsTr("No body here! :/")
color: root.modelData.urgency === "critical" ? Colours.palette.m3secondary : Colours.palette.m3outline color: root.modelData?.urgency === "critical" ? Colours.palette.m3secondary : Colours.palette.m3outline
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
onLinkActivated: link => { onLinkActivated: link => {

View file

@ -101,7 +101,7 @@ Item {
{ {
isClose: true isClose: true
}, },
...root.notif.actions, ...(root.notif?.actions ?? []),
{ {
isCopy: true isCopy: true
} }