Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

filter: Remove unused parts of is_valid_search_term.

evykassirerec2d280b7b79
diff --git a/web/src/filter.ts b/web/src/filter.ts
index aa95d54f213..00a29378cad 100644
--- a/web/src/filter.ts
+++ b/web/src/filter.ts
@@ -482,32 +482,7 @@ export class Filter {
return terms;
}
- static is_valid_search_term(
- term: NarrowTerm,
- allow_valid_operator_with_empty_operand = false,
- ): boolean {
- // `allow_valid_operator_with_empty_operand` is used for validating
- // partial terms for search suggestions, e.g. "dm:" shows
- // "Direct messages with" so it's valid. Note that we don't show messages
- // in search suggestions for empty "is:" or "has:".
- if (allow_valid_operator_with_empty_operand && term.operand === "") {
- return [
- "in",
- "id",
- "near",
- "channel",
- "stream",
- "topic",
- "sender",
- "from",
- "dm",
- "pm",
- "pm-with",
- "dm-including",
- "pm-including",
- "search",
- ].includes(term.operator);
- }
+ static is_valid_search_term(term: NarrowTerm): boolean {
switch (term.operator) {
case "has":
return ["image", "link", "attachment", "reaction"].includes(term.operand);
diff --git a/web/tests/filter.test.js b/web/tests/filter.test.js
index 995d463c094..edfa1e412e0 100644
--- a/web/tests/filter.test.js
+++ b/web/tests/filter.test.js
@@ -1698,12 +1698,6 @@ test("is_valid_search_term", () => {
}),
false,
);
-
- // test `allow_valid_operator_with_empty_operand`
- assert.equal(Filter.is_valid_search_term(Filter.parse("dm: ")[0]), false);
- assert.equal(Filter.is_valid_search_term(Filter.parse("dm: ")[0], true), true);
- // Note that this is parsed as a search operator term and therefore is valid.
- assert.equal(Filter.is_valid_search_term(Filter.parse("foo: ")[0], true), true);
});
test("update_email", () => {