From 858bca0f7d1494bb05a1c41338ddeee0ea89120f Mon Sep 17 00:00:00 2001 From: Michael Shamoon <4887959+nikonratm@users.noreply.github.com> Date: Wed, 6 Jan 2021 11:12:43 -0800 Subject: [PATCH] More efficient rule equivalency checking --- .../document-list/document-list.component.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src-ui/src/app/components/document-list/document-list.component.ts b/src-ui/src/app/components/document-list/document-list.component.ts index 72c499568..9b88c13b4 100644 --- a/src-ui/src/app/components/document-list/document-list.component.ts +++ b/src-ui/src/app/components/document-list/document-list.component.ts @@ -121,7 +121,7 @@ export class DocumentListComponent implements OnInit { } resetFilters(): void { - this.filterRulesModified = false; + this.filterRulesModified = false if (this.list.savedViewId) { this.savedViewService.getCached(this.list.savedViewId).subscribe(viewUntouched => { this.list.filterRules = viewUntouched.filter_rules @@ -144,12 +144,16 @@ export class DocumentListComponent implements OnInit { if (this.list.filterRules.length !== filterRulesInitial.length) modified = true else { - this.list.filterRules.forEach(rule => { - if (filterRulesInitial.find(fri => fri.rule_type == rule.rule_type && fri.value == rule.value) == undefined) modified = true - }) - filterRulesInitial.forEach(rule => { - if (this.list.filterRules.find(fr => fr.rule_type == rule.rule_type && fr.value == rule.value) == undefined) modified = true + modified = this.list.filterRules.some(rule => { + return (filterRulesInitial.find(fri => fri.rule_type == rule.rule_type && fri.value == rule.value) == undefined) }) + + if (!modified) { + // only check other direction if we havent already determined is modified + modified = filterRulesInitial.some(rule => { + this.list.filterRules.find(fr => fr.rule_type == rule.rule_type && fr.value == rule.value) == undefined + }) + } } }) }