Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
resolved_topic: Add and use predicate is_resolved.
Greg Price7bf0fd3fa3fc
diff --git a/frontend_tests/node_tests/compose_validate.js b/frontend_tests/node_tests/compose_validate.jsindex 52e5641f05b..d4cbe5991a3 100644--- a/frontend_tests/node_tests/compose_validate.js+++ b/frontend_tests/node_tests/compose_validate.js@@ -770,7 +770,7 @@ test_ui("test warn_if_topic_resolved", ({override, mock_template}) => {mock_template("compose_resolved_topic.hbs", false, (context) => {assert.ok(context.can_move_topic);- assert.ok(context.topic_name.startsWith(resolved_topic.RESOLVED_TOPIC_PREFIX));+ assert.ok(resolved_topic.is_resolved(context.topic_name));return "fake-compose_resolved_topic";});diff --git a/frontend_tests/node_tests/resolved_topic.js b/frontend_tests/node_tests/resolved_topic.jsnew file mode 100644index 00000000000..3136fb84cfd--- /dev/null+++ b/frontend_tests/node_tests/resolved_topic.js@@ -0,0 +1,20 @@+"use strict";++const {strict: assert} = require("assert");++const {zrequire} = require("../zjsunit/namespace");+const {run_test} = require("../zjsunit/test");++const resolved_topic = zrequire("../shared/js/resolved_topic");++const topic_name = "asdf";+const resolved_name = "✔ " + topic_name;+const overresolved_name = "✔ ✔✔ " + topic_name;+const pseudoresolved_name = "✔" + topic_name; // check mark, but no space++run_test("is_resolved", () => {+ assert.ok(!resolved_topic.is_resolved(topic_name));+ assert.ok(resolved_topic.is_resolved(resolved_name));+ assert.ok(resolved_topic.is_resolved(overresolved_name));+ assert.ok(!resolved_topic.is_resolved(pseudoresolved_name));+});diff --git a/static/js/compose_validate.js b/static/js/compose_validate.jsindex 5abb6ed64fa..40586d77163 100644--- a/static/js/compose_validate.js+++ b/static/js/compose_validate.js@@ -178,7 +178,7 @@ export function warn_if_topic_resolved() {const sub = stream_data.get_sub(stream_name);- if (sub && topic_name.startsWith(resolved_topic.RESOLVED_TOPIC_PREFIX)) {+ if (sub && resolved_topic.is_resolved(topic_name)) {const error_area = $("#compose_resolved_topic");if (error_area.html()) {diff --git a/static/js/filter.js b/static/js/filter.jsindex fb73d281a58..ccc83320f17 100644--- a/static/js/filter.js+++ b/static/js/filter.js@@ -96,10 +96,7 @@ function message_matches_search_term(message, operator, operand) {case "unread":return unread.message_unread(message);case "resolved":- return (- message.type === "stream" &&- message.topic.startsWith(resolved_topic.RESOLVED_TOPIC_PREFIX)- );+ return message.type === "stream" && resolved_topic.is_resolved(message.topic);default:return false; // is:whatever returns false}diff --git a/static/js/message_list_view.js b/static/js/message_list_view.jsindex 0f5b52779d1..6ea6a13f61f 100644--- a/static/js/message_list_view.js+++ b/static/js/message_list_view.js@@ -182,7 +182,7 @@ function populate_group_from_message_container(group, message_container) {} else {group.stream_id = sub.stream_id;}- group.topic_is_resolved = group.topic.startsWith(resolved_topic.RESOLVED_TOPIC_PREFIX);+ group.topic_is_resolved = resolved_topic.is_resolved(group.topic);group.topic_muted = muted_topics.is_topic_muted(group.stream_id, group.topic);} else if (group.is_private) {group.pm_with_url = message_container.pm_with_url;diff --git a/static/js/stream_popover.js b/static/js/stream_popover.jsindex 58a0a52b15e..a20dc8ac022 100644--- a/static/js/stream_popover.js+++ b/static/js/stream_popover.js@@ -291,7 +291,7 @@ function build_topic_popover(opts) {topic_muted,can_move_topic,is_realm_admin: page_params.is_admin,- topic_is_resolved: topic_name.startsWith(resolved_topic.RESOLVED_TOPIC_PREFIX),+ topic_is_resolved: resolved_topic.is_resolved(topic_name),color: sub.color,has_starred_messages,});diff --git a/static/shared/js/resolved_topic.js b/static/shared/js/resolved_topic.jsindex 6175cd1639c..404beca9735 100644--- a/static/shared/js/resolved_topic.js+++ b/static/shared/js/resolved_topic.js@@ -1,2 +1,6 @@/** The canonical form of the resolved-topic prefix. */export const RESOLVED_TOPIC_PREFIX = "✔ ";++export function is_resolved(topic_name) {+ return topic_name.startsWith(RESOLVED_TOPIC_PREFIX);+}diff --git a/static/shared/js/resolved_topic.js.flow b/static/shared/js/resolved_topic.js.flowindex cbe6e066c78..a3f754d82ef 100644--- a/static/shared/js/resolved_topic.js.flow+++ b/static/shared/js/resolved_topic.js.flow@@ -1,3 +1,5 @@// @flow strictdeclare export var RESOLVED_TOPIC_PREFIX: string;++declare export function is_resolved(topic_name: string): boolean;