Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
search: Exclude `with` operator terms from search terms.
roanster007ca2394495ea9
diff --git a/web/src/narrow_state.ts b/web/src/narrow_state.tsindex 36d64d9250a..0bb7273ef67 100644--- a/web/src/narrow_state.ts+++ b/web/src/narrow_state.ts@@ -18,11 +18,15 @@ export function filter(): Filter | undefined {export function search_terms(current_filter: Filter | undefined = filter()): NarrowTerm[] {if (current_filter === undefined) {if (page_params.narrow !== undefined) {- return new Filter(page_params.narrow).terms();+ current_filter = new Filter(page_params.narrow);+ } else {+ current_filter = new Filter([]);}- return new Filter([]).terms();}- return current_filter.terms();++ const non_search_operators = new Set(["with"]);++ return current_filter.terms().filter((term) => !non_search_operators.has(term.operator));}export function is_search_view(current_filter: Filter | undefined = filter()): boolean {diff --git a/web/tests/narrow_state.test.cjs b/web/tests/narrow_state.test.cjsindex 2fdef261ed3..13d0426290e 100644--- a/web/tests/narrow_state.test.cjs+++ b/web/tests/narrow_state.test.cjs@@ -151,6 +151,17 @@ test("terms", () => {assert.equal(result.length, 1);assert.equal(result[0].operator, "channel");assert.equal(result[0].operand, foo_stream_id.toString());++ // `with` terms are excluded from search terms.+ page_params.narrow = [+ {operator: "stream", operand: foo_stream_id.toString()},+ {operator: "topic", operand: "Bar"},+ {operator: "with", operand: "12"},+ ];+ result = narrow_state.search_terms();+ assert.equal(result.length, 2);+ assert.equal(result[0].operator, "channel");+ assert.equal(result[1].operator, "topic");});test("excludes_muted_topics", () => {