fix(notification-rules): do not allow empty patterns

This commit is contained in:
Lysec
2026-03-18 21:31:49 +01:00
parent 381444bc2c
commit bc258254d8
4 changed files with 9 additions and 4 deletions
@@ -110,6 +110,7 @@ Popup {
icon: "check"
backgroundColor: Color.mPrimary
textColor: Color.mOnPrimary
enabled: patternInput.text.trim() !== ""
onClicked: {
root.saved(patternInput.text.trim(), _selectedAction || "block");
root.close();
@@ -37,8 +37,11 @@ ColumnLayout {
} catch (e) {}
editPopup._savedSlot = function (pattern, action) {
const trimmed = (pattern || "").trim();
if (trimmed === "")
return;
var arr = (NotificationRulesService.rules || []).slice();
var rule = { "pattern": pattern, "action": action };
var rule = { "pattern": trimmed, "action": action };
if (index >= 0 && index < arr.length) {
arr[index] = rule;
} else {
@@ -80,7 +83,7 @@ ColumnLayout {
NLabel {
Layout.fillWidth: true
label: (entryDelegate.isRegex ? "regex: " : "") + (entryDelegate.pattern || I18n.tr("panels.notifications.rules-empty-pattern"))
label: (entryDelegate.isRegex ? "regex: " : "") + entryDelegate.pattern
description: entryDelegate.action === "block" ? I18n.tr("panels.notifications.rules-action-block") : (entryDelegate.action === "mute" ? I18n.tr("panels.notifications.rules-action-mute") : I18n.tr("panels.notifications.rules-action-hide"))
labelColor: entryDelegate.pattern ? Color.mPrimary : Color.mOnSurface
}