mirror of https://github.com/zulip/zulip.git
refactor: Extract stream_list.maybe_activate_stream_item().
This commit is contained in:
parent
1a11042fdf
commit
5b6bd6767b
|
@ -356,6 +356,25 @@ exports.refresh_pinned_or_unpinned_stream = function (sub) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.maybe_activate_stream_item = function (filter) {
|
||||||
|
var op_stream = filter.operands('stream');
|
||||||
|
if (op_stream.length !== 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)) {
|
||||||
|
var stream_li = exports.get_stream_li(stream_id);
|
||||||
|
var op_subject = filter.operands('topic');
|
||||||
|
if (op_subject.length === 0) {
|
||||||
|
stream_li.addClass('active-filter');
|
||||||
|
}
|
||||||
|
rebuild_recent_topics(stream_name);
|
||||||
|
|
||||||
|
return stream_li;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
function deselect_top_left_corner_items() {
|
function deselect_top_left_corner_items() {
|
||||||
$("ul.filters li").removeClass('active-filter active-sub-filter');
|
$("ul.filters li").removeClass('active-filter active-sub-filter');
|
||||||
}
|
}
|
||||||
|
@ -396,22 +415,11 @@ $(function () {
|
||||||
pm_list.close();
|
pm_list.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
var op_stream = event.filter.operands('stream');
|
var stream_li = exports.maybe_activate_stream_item(event.filter);
|
||||||
if (op_stream.length !== 0) {
|
if (stream_li) {
|
||||||
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)) {
|
|
||||||
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();
|
unread_ops.process_visible();
|
||||||
exports.scroll_to_active_stream(stream_li);
|
exports.scroll_to_active_stream(stream_li);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('narrow_deactivated.zulip', function () {
|
$(document).on('narrow_deactivated.zulip', function () {
|
||||||
|
|
Loading…
Reference in New Issue