From f706efe12e7b1fc7b0dc6ea582463de52fb98aaa Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Thu, 10 Aug 2017 18:29:35 -0400 Subject: [PATCH] Add topic_list.active_stream_id(). --- frontend_tests/node_tests/topic_list.js | 4 ++++ static/js/topic_list.js | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/frontend_tests/node_tests/topic_list.js b/frontend_tests/node_tests/topic_list.js index f259356b3a..855b53ff48 100644 --- a/frontend_tests/node_tests/topic_list.js +++ b/frontend_tests/node_tests/topic_list.js @@ -74,6 +74,8 @@ zrequire('topic_list'); attached_to_parent = true; }; + assert.equal(topic_list.active_stream_id(), undefined); + var widget = topic_list.build_widget(parent_elem, stream_id, active_topic, max_topics); assert(widget.is_for_stream(stream_id)); @@ -83,4 +85,6 @@ zrequire('topic_list'); assert(rendered); assert(item_appended); assert(attached_to_parent); + + assert.equal(topic_list.active_stream_id(), stream_id); }()); diff --git a/static/js/topic_list.js b/static/js/topic_list.js index 0b70e790d0..bdf0f163f9 100644 --- a/static/js/topic_list.js +++ b/static/js/topic_list.js @@ -155,6 +155,14 @@ exports.build_widget = function (parent_elem, my_stream_id, active_topic, max_to return self; }; +exports.active_stream_id = function () { + if (!active_widget) { + return; + } + + return active_widget.get_stream_id(); +}; + exports.rebuild = function (stream_li, stream_id) { var max_topics = 5;