topic list: Add is_active_topic to template.

The only place we ever set active-sub-filter is
right after we build the template, so there is
no reason to have it be a separate step.

(I made a similar fix to pm_list recently, and
this helps set the stage for doing vdom-like
stuff.)
This commit is contained in:
Steve Howell 2020-01-17 20:40:28 +00:00 committed by Tim Abbott
parent e459a4b7a7
commit 613b8ade20
3 changed files with 3 additions and 12 deletions

View File

@ -49,6 +49,7 @@ run_test('topic_list_build_widget', () => {
unread: 3,
is_zero: false,
is_muted: false,
is_active_topic: false,
url: '#narrow/stream/555-devel/topic/coding',
};
assert.deepEqual(info, expected);

View File

@ -162,6 +162,7 @@ exports.widget = function (parent_elem, my_stream_id) {
unread: num_unread,
is_zero: num_unread === 0,
is_muted: is_topic_muted,
is_active_topic: is_active_topic,
url: hash_util.by_stream_topic_uri(my_stream_id, topic_name),
};
const li = $(render_topic_list_item(topic_info));
@ -275,13 +276,6 @@ exports.widget = function (parent_elem, my_stream_id) {
return false;
};
self.activate_topic = function () {
const li = self.topic_items.get(self.active_topic);
if (li) {
li.addClass('active-sub-filter');
}
};
self.show_spinner = function () {
// The spinner will go away once we get results and redraw
// the whole list.
@ -314,10 +308,6 @@ exports.widget = function (parent_elem, my_stream_id) {
if (no_more_topics) {
self.show_no_more_topics();
}
if (active_topic) {
self.activate_topic();
}
};
return self;

View File

@ -1,4 +1,4 @@
<li class='bottom_left_row {{#if is_zero}}zero-topic-unreads{{/if}} {{#if is_muted}}muted_topic{{/if}} topic-list-item' data-topic-name='{{topic_name}}'>
<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'>
<a href='{{url}}' class="topic-name" title="{{topic_name}}">
{{topic_name}}