mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 07:23:22 +00:00
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:
committed by
Tim Abbott
parent
1c6435d4cc
commit
40a6602b09
@@ -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;
|
||||
});
|
||||
|
||||
@@ -166,7 +166,10 @@ exports.update_messages = function update_messages(events) {
|
||||
if (selection_changed_topic) {
|
||||
if (current_filter && stream_name) {
|
||||
if (current_filter.has_topic(stream_name, orig_topic)) {
|
||||
const new_filter = current_filter.filter_with_new_topic(new_topic);
|
||||
const new_filter = current_filter.filter_with_new_params({
|
||||
operator: 'topic',
|
||||
operand: new_topic,
|
||||
});
|
||||
const operators = new_filter.operators();
|
||||
const opts = {
|
||||
trigger: 'topic change',
|
||||
|
||||
Reference in New Issue
Block a user