mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
fix(notification-rules): do not allow empty patterns
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user