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.

topic_list_data: Move "if resolved" conditionals to a single place.

Greg Price7852d8e0159a
diff --git a/frontend_tests/node_tests/topic_list_data.js b/frontend_tests/node_tests/topic_list_data.js
index 0812eb5c653..a1c20da1c6e 100644
--- a/frontend_tests/node_tests/topic_list_data.js
+++ b/frontend_tests/node_tests/topic_list_data.js
@@ -83,10 +83,9 @@ test("get_list_info w/real stream_topic_history", ({override}) => {
is_active_topic: true,
is_muted: false,
is_zero: true,
- resolved: false,
- resolved_topic_prefix: "✔ ",
topic_display_name: "topic 6",
topic_name: "topic 6",
+ topic_resolved_prefix: "",
unread: 0,
url: "#narrow/stream/556-general/topic/topic.206",
});
@@ -95,10 +94,9 @@ test("get_list_info w/real stream_topic_history", ({override}) => {
is_active_topic: false,
is_muted: false,
is_zero: true,
- resolved: true,
- resolved_topic_prefix: "✔ ",
topic_display_name: "topic 5",
topic_name: "✔ topic 5",
+ topic_resolved_prefix: "✔ ",
unread: 0,
url: "#narrow/stream/556-general/topic/.E2.9C.94.20topic.205",
});
diff --git a/static/js/topic_list_data.js b/static/js/topic_list_data.js
index 7f4b935d656..3ea67fe1d10 100644
--- a/static/js/topic_list_data.js
+++ b/static/js/topic_list_data.js
@@ -33,10 +33,12 @@ export function get_list_info(stream_id, zoomed) {
const num_unread = unread.num_unread_for_topic(stream_id, topic_name);
const is_active_topic = active_topic === topic_name.toLowerCase();
const is_topic_muted = muted_topics.is_topic_muted(stream_id, topic_name);
- const resolved = topic_name.startsWith(resolved_topic.RESOLVED_TOPIC_PREFIX);
- let topic_display_name = topic_name;
+ let topic_resolved_prefix = "";
+ let topic_display_name = topic_name;
+ const resolved = topic_name.startsWith(resolved_topic.RESOLVED_TOPIC_PREFIX);
if (resolved) {
+ topic_resolved_prefix = resolved_topic.RESOLVED_TOPIC_PREFIX;
topic_display_name = topic_display_name.slice(
resolved_topic.RESOLVED_TOPIC_PREFIX.length,
);
@@ -101,14 +103,13 @@ export function get_list_info(stream_id, zoomed) {
const topic_info = {
topic_name,
+ topic_resolved_prefix,
topic_display_name,
unread: num_unread,
is_zero: num_unread === 0,
is_muted: is_topic_muted,
is_active_topic,
url: hash_util.by_stream_topic_url(stream_id, topic_name),
- resolved,
- resolved_topic_prefix: resolved_topic.RESOLVED_TOPIC_PREFIX,
};
items.push(topic_info);
diff --git a/static/templates/topic_list_item.hbs b/static/templates/topic_list_item.hbs
index d4e6c7e9a3d..ba2858f67a9 100644
--- a/static/templates/topic_list_item.hbs
+++ b/static/templates/topic_list_item.hbs
@@ -1,9 +1,7 @@
<li class='bottom_left_row {{#if is_active_topic}}active-sub-filter{{/if}} {{#if is_zero}}zero-topic-unreads{{/if}} {{#if is_muted}}muted_topic{{/if}} topic-list-item' data-topic-name='{{topic_name}}'>
<span class='topic-box'>
<span class="sidebar-topic-check">
- {{#if resolved}}
- {{resolved_topic_prefix}}
- {{/if}}
+ {{topic_resolved_prefix}}
</span>
<a href='{{url}}' class="topic-name" title="{{topic_name}}">
{{topic_display_name}}