Extract topic_list.build_list().

This used to be stream_list._build_subject_list().  The code
didn't change except for one s/subject/topic fix.
This commit is contained in:
Steve Howell
2016-10-26 17:02:40 -07:00
committed by Tim Abbott
parent 8783a0e51d
commit f7e6cfc892
3 changed files with 47 additions and 44 deletions

View File

@@ -360,46 +360,6 @@ exports.remove_narrow_filter = function (name, type) {
get_filter_li(type, name).remove();
};
exports._build_subject_list = function (stream, active_topic, max_subjects) {
var subjects = stream_data.recent_subjects.get(stream) || [];
if (active_topic) {
active_topic = active_topic.toLowerCase();
}
var display_subjects = [];
var hiding_topics = false;
_.each(subjects, function (subject_obj, idx) {
var topic_name = subject_obj.subject;
var num_unread = unread.num_unread_for_subject(stream, subject_obj.canon_subject);
// Show the most recent subjects, as well as any with unread messages
var always_visible = (idx < max_subjects) || (num_unread > 0) || (active_topic === topic_name);
if (!always_visible) {
hiding_topics = true;
}
var display_subject = {
topic_name: topic_name,
unread: num_unread,
is_zero: num_unread === 0,
is_muted: muting.is_topic_muted(stream, topic_name),
zoom_out_hide: !always_visible,
url: narrow.by_stream_subject_uri(stream, topic_name)
};
display_subjects.push(display_subject);
});
var topic_dom = templates.render('sidebar_subject_list',
{subjects: display_subjects,
want_show_more_topics_links: hiding_topics,
stream: stream});
return topic_dom;
};
exports._build_private_messages_list = function (active_conversation, max_private_messages) {
var private_messages = message_store.recent_private_messages || [];
@@ -443,7 +403,7 @@ function rebuild_recent_topics(stream, active_topic) {
var max_subjects = 5;
var stream_li = get_filter_li('stream', stream);
var topic_dom = exports._build_subject_list(stream, active_topic, max_subjects);
var topic_dom = topic_list.build_list(stream, active_topic, max_subjects);
stream_li.append(topic_dom);
if (active_topic) {