Improve error reporting in maybe_activate_stream_item.

This change should lead to clearer tracebacks when our
assumption about the stream list's list items get
violated, and we also short circuit some code in the
caller that tries to scroll to the active stream.
This commit is contained in:
Steve Howell 2017-05-30 14:18:18 -06:00 committed by Tim Abbott
parent 561fba65d2
commit e7345bdd7f
1 changed files with 11 additions and 0 deletions

View File

@ -359,6 +359,17 @@ exports.maybe_activate_stream_item = function (filter) {
if (stream_id && stream_data.id_is_subscribed(stream_id)) { if (stream_id && stream_data.id_is_subscribed(stream_id)) {
var stream_li = exports.get_stream_li(stream_id); var stream_li = exports.get_stream_li(stream_id);
if (stream_li.length !== 1) {
// It should be the case then when we have a subscribed
// stream, there will always be a stream list item
// corresponding to that stream in our sidebar. We have
// evidence that this assumption breaks down for some users,
// but we are not clear why it happens.
blueslip.error('No stream_li for subscribed stream ' + stream_name);
return;
}
var op_subject = filter.operands('topic'); var op_subject = filter.operands('topic');
if (op_subject.length === 0) { if (op_subject.length === 0) {
stream_li.addClass('active-filter'); stream_li.addClass('active-filter');