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: Add new is_non_huddle_pm method.

Abhijeet Prasad Bodase4d5114c3c36
diff --git a/frontend_tests/node_tests/filter.js b/frontend_tests/node_tests/filter.js
index eae5d0a8c31..a1f8f452318 100644
--- a/frontend_tests/node_tests/filter.js
+++ b/frontend_tests/node_tests/filter.js
@@ -185,13 +185,20 @@ test("basics", () => {
operators = [{operator: "pm-with", operand: "[email protected]"}];
filter = new Filter(operators);
+ assert(filter.is_non_huddle_pm());
assert(filter.contains_only_private_messages());
assert(!filter.has_operator("search"));
assert(filter.can_apply_locally());
assert(!filter.is_personal_filter());
+ operators = [{operator: "pm-with", operand: "[email protected],[email protected]"}];
+ filter = new Filter(operators);
+ assert(!filter.is_non_huddle_pm());
+ assert(filter.contains_only_private_messages());
+
operators = [{operator: "group-pm-with", operand: "[email protected]"}];
filter = new Filter(operators);
+ assert(!filter.is_non_huddle_pm());
assert(filter.contains_only_private_messages());
assert(!filter.has_operator("search"));
assert(filter.can_apply_locally());
diff --git a/static/js/filter.js b/static/js/filter.js
index dba23422270..8077ce74987 100644
--- a/static/js/filter.js
+++ b/static/js/filter.js
@@ -412,6 +412,10 @@ export class Filter {
return this.has_operator("search");
}
+ is_non_huddle_pm() {
+ return this.has_operator("pm-with") && this.operands("pm-with")[0].split(",").length === 1;
+ }
+
calc_can_mark_messages_read() {
const term_types = this.sorted_term_types();