Skip to content

Commit

Permalink
use deep copies to emit filters
Browse files Browse the repository at this point in the history
  • Loading branch information
infacc committed Jul 19, 2023
1 parent b8b6cf6 commit 16dd6a5
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class PluginFilterNodeComponent implements OnInit {

setupFilter() {
this.isEmpty = Object.keys(this.filterIn).length === 0;
this.filterObject = { ...this.filterIn };
this.filterObject = JSON.parse(JSON.stringify(this.filterIn));
const filter = this.filterObject.not ?? this.filterObject;
this.inverted = this.filterObject.not != null;
if (filter == null) {
Expand Down Expand Up @@ -72,7 +72,7 @@ export class PluginFilterNodeComponent implements OnInit {
console.warn("No type provided to plugin filter node component");
return;
}
const filter = { ...this.filterObject };
const filter = JSON.parse(JSON.stringify(this.filterObject));
if (this.inverted) {
filter.not[this.type] = this.children ?? this.value;
} else {
Expand Down Expand Up @@ -126,7 +126,7 @@ export class PluginFilterNodeComponent implements OnInit {
if (type == null || this.type === type) {
return;
}
const filter = { ...(this.filterObject.not ?? this.filterObject) };
const filter = this.filterObject.not ?? this.filterObject;
const isLeaf = type !== 'and' && type !== 'or';
if (this.type != null) {
delete filter[this.type]
Expand All @@ -139,7 +139,7 @@ export class PluginFilterNodeComponent implements OnInit {
this.value = null;
filter[type] = this.children ?? [];
}
this.filterOut.emit(filter);
this.filterOut.emit(JSON.parse(JSON.stringify(this.filterObject)));
}

updateFilterString(event: any) {
Expand All @@ -154,6 +154,6 @@ export class PluginFilterNodeComponent implements OnInit {
} else {
this.filterObject = this.filterObject.not;
}
this.filterOut.emit({ ...this.filterObject });
this.filterOut.emit(JSON.parse(JSON.stringify(this.filterObject)));
}
}

0 comments on commit 16dd6a5

Please sign in to comment.