filters: Refactor filter_with_new_topic to expand its functionality.

This intent is that we'll be able to reuse this when editing streams
as well.

* Rename method: filter_with_new_topic to filter_with_new_param.
* Fix tests and method calls.
This commit is contained in:
Wbert Adrian Castro Vera
2020-03-05 13:01:38 -05:00
committed by Tim Abbott
parent 1c6435d4cc
commit 40a6602b09
3 changed files with 11 additions and 5 deletions

View File

@@ -486,11 +486,11 @@ Filter.prototype = {
return operators_mixed_case.map(tuple => Filter.canonicalize_term(tuple));
},
filter_with_new_topic: function (new_topic) {
filter_with_new_params: function (params) {
const terms = this._operators.map(term => {
const new_term = { ...term };
if (new_term.operator === 'topic' && !new_term.negated) {
new_term.operand = new_topic;
if (new_term.operator === params.operator && !new_term.negated) {
new_term.operand = params.operand;
}
return new_term;
});