mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-24 16:51:07 +01:00
checks
This commit is contained in:
parent
a29ccda68e
commit
55902b58ac
@ -89,18 +89,19 @@ class VectorSettingsAdvancedNotificationPreferenceFragment @Inject constructor()
|
||||
|
||||
private fun getNotificationIndexForRule(rule: PushRule): NotificationIndex? {
|
||||
return NotificationIndex.values().firstOrNull {
|
||||
// Get the actions for the index
|
||||
val standardAction = getStandardAction(rule.ruleId, it) ?: return@firstOrNull false
|
||||
val indexActions = standardAction.actions ?: listOf()
|
||||
// Check if the input rule matches a rule generated from the static rule definitions
|
||||
val targetRule = rule.copy(enabled = standardAction != StandardAction.Disabled, actions = indexActions.toJson())
|
||||
val match = ruleMatches(rule, targetRule)
|
||||
match
|
||||
ruleMatches(rule, targetRule)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun ruleMatches(rule: PushRule, targetRule: PushRule): Boolean {
|
||||
return (!rule.enabled && !targetRule.enabled) ||
|
||||
(rule.enabled
|
||||
//Rules match if both are disabled, or if both are enabled and their highlight/sound/notify actions match up.
|
||||
return (!rule.enabled && !targetRule.enabled)
|
||||
|| (rule.enabled
|
||||
&& targetRule.enabled
|
||||
&& rule.getHighlight() == targetRule.getHighlight()
|
||||
&& rule.getNotificationSound() == targetRule.getNotificationSound()
|
||||
@ -108,7 +109,6 @@ class VectorSettingsAdvancedNotificationPreferenceFragment @Inject constructor()
|
||||
&& rule.shouldNotNotify() == targetRule.shouldNotNotify())
|
||||
}
|
||||
|
||||
|
||||
private fun refreshDisplay() {
|
||||
listView?.adapter?.notifyDataSetChanged()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user