mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
simplify filter rule comparison
This commit is contained in:
parent
ffb903841b
commit
5c9ad3068b
@ -29,28 +29,19 @@ export function filterRulesDiffer(
|
|||||||
filterRulesA: FilterRule[],
|
filterRulesA: FilterRule[],
|
||||||
filterRulesB: FilterRule[]
|
filterRulesB: FilterRule[]
|
||||||
): boolean {
|
): boolean {
|
||||||
let modified = false
|
let differ = false
|
||||||
if (filterRulesA.length != filterRulesB.length) {
|
if (filterRulesA.length != filterRulesB.length) {
|
||||||
modified = true
|
differ = true
|
||||||
} else {
|
} else {
|
||||||
modified = filterRulesA.some((rule) => {
|
differ = filterRulesA.some((rule) => {
|
||||||
return (
|
return (
|
||||||
filterRulesB.find(
|
filterRulesB.find(
|
||||||
(fri) => fri.rule_type == rule.rule_type && fri.value == rule.value
|
(fri) => fri.rule_type == rule.rule_type && fri.value == rule.value
|
||||||
) == undefined
|
) == undefined
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!modified) {
|
|
||||||
// only check other direction if we havent already determined is modified
|
|
||||||
modified = filterRulesB.some((rule) => {
|
|
||||||
filterRulesA.find(
|
|
||||||
(fr) => fr.rule_type == rule.rule_type && fr.value == rule.value
|
|
||||||
) == undefined
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return modified
|
return differ
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FilterRule {
|
export interface FilterRule {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user