mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-13 17:22:08 -04:00
feat(notifications): add configurable notification rules (#1655)
This commit is contained in:
@@ -504,6 +504,7 @@ Singleton {
|
||||
property bool notificationHistorySaveLow: true
|
||||
property bool notificationHistorySaveNormal: true
|
||||
property bool notificationHistorySaveCritical: true
|
||||
property var notificationRules: []
|
||||
|
||||
property bool osdAlwaysShowValue: false
|
||||
property int osdPosition: SettingsData.Position.BottomCenter
|
||||
@@ -2134,6 +2135,56 @@ Singleton {
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
function addNotificationRule() {
|
||||
var rules = JSON.parse(JSON.stringify(notificationRules || []));
|
||||
rules.push({
|
||||
enabled: true,
|
||||
field: "appName",
|
||||
pattern: "",
|
||||
matchType: "contains",
|
||||
action: "mute",
|
||||
urgency: "default"
|
||||
});
|
||||
notificationRules = rules;
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
function updateNotificationRule(index, ruleData) {
|
||||
var rules = JSON.parse(JSON.stringify(notificationRules || []));
|
||||
if (index < 0 || index >= rules.length)
|
||||
return;
|
||||
var existing = rules[index] || {};
|
||||
rules[index] = Object.assign({}, existing, ruleData || {});
|
||||
notificationRules = rules;
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
function updateNotificationRuleField(index, key, value) {
|
||||
if (key === undefined || key === null || key === "")
|
||||
return;
|
||||
var patch = {};
|
||||
patch[key] = value;
|
||||
updateNotificationRule(index, patch);
|
||||
}
|
||||
|
||||
function removeNotificationRule(index) {
|
||||
var rules = JSON.parse(JSON.stringify(notificationRules || []));
|
||||
if (index < 0 || index >= rules.length)
|
||||
return;
|
||||
rules.splice(index, 1);
|
||||
notificationRules = rules;
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
function getDefaultNotificationRules() {
|
||||
return Spec.SPEC.notificationRules.def;
|
||||
}
|
||||
|
||||
function resetNotificationRules() {
|
||||
notificationRules = JSON.parse(JSON.stringify(Spec.SPEC.notificationRules.def));
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
function getDefaultAppIdSubstitutions() {
|
||||
return Spec.SPEC.appIdSubstitutions.def;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user