Add stream_data.id_is_subscribed().

We use this function in stream_list.js.
This commit is contained in:
Steve Howell
2017-05-14 07:32:18 -07:00
committed by Tim Abbott
parent efb35afeb7
commit 762194f98d
2 changed files with 20 additions and 10 deletions

View File

@@ -200,6 +200,11 @@ exports.is_subscribed = function (stream_name) {
return sub !== undefined && sub.subscribed;
};
exports.id_is_subscribed = function (stream_id) {
var sub = subs_by_stream_id.get(stream_id);
return sub !== undefined && sub.subscribed;
};
exports.get_invite_only = function (stream_name) {
var sub = exports.get_sub(stream_name);
if (sub === undefined) {

View File

@@ -296,8 +296,10 @@ exports.update_streams_sidebar = function () {
var op_stream = narrow_state.filter().operands('stream');
if (op_stream.length !== 0) {
if (stream_data.is_subscribed(op_stream[0])) {
rebuild_recent_topics(op_stream[0]);
var stream_name = op_stream[0];
var stream_id = stream_data.get_stream_id(stream_name);
if (stream_id && stream_data.id_is_subscribed(stream_id)) {
rebuild_recent_topics(stream_name);
}
}
};
@@ -395,17 +397,20 @@ $(function () {
}
var op_stream = event.filter.operands('stream');
if (op_stream.length !== 0 && stream_data.is_subscribed(op_stream[0])) {
if (op_stream.length !== 0) {
var stream_name = op_stream[0];
var stream_id = stream_data.get_stream_id(stream_name);
var stream_li = exports.get_stream_li(stream_id);
var op_subject = event.filter.operands('topic');
if (op_subject.length === 0) {
stream_li.addClass('active-filter');
if (stream_id && stream_data.id_is_subscribed(stream_id)) {
var stream_li = exports.get_stream_li(stream_id);
var op_subject = event.filter.operands('topic');
if (op_subject.length === 0) {
stream_li.addClass('active-filter');
}
rebuild_recent_topics(stream_name);
unread_ops.process_visible();
exports.scroll_to_active_stream(stream_li);
}
rebuild_recent_topics(stream_name);
unread_ops.process_visible();
exports.scroll_to_active_stream(stream_li);
}
});