Extract stream_data.is_active().

This commit is contained in:
Steve Howell 2016-10-28 08:18:56 -07:00 committed by Tim Abbott
parent ecbd77d8a5
commit c799ac3126
2 changed files with 7 additions and 4 deletions

View File

@ -16,6 +16,9 @@ exports.clear_subscriptions = function () {
exports.recent_subjects = new Dict({fold_case: true});
exports.clear_subscriptions();
exports.is_active = function (stream_name) {
return exports.recent_subjects.has(stream_name);
};
exports.add_sub = function (stream_name, sub) {
if (!_.has(sub, 'subscribers')) {

View File

@ -78,7 +78,7 @@ exports.build_stream_list = function () {
function add_sidebar_li(stream) {
var li = $(stream_data.get_sub(stream).sidebar_li);
if (sort_recent) {
if (stream_data.recent_subjects.has(stream)) {
if (stream_data.is_active(stream)) {
li.removeClass('inactive_stream');
} else {
li.addClass('inactive_stream');
@ -98,9 +98,9 @@ exports.build_stream_list = function () {
unpinned_streams.sort(function (a, b) {
if (sort_recent) {
if (stream_data.recent_subjects.has(b) && ! stream_data.recent_subjects.has(a)) {
if (stream_data.is_active(b) && ! stream_data.is_active(a)) {
return 1;
} else if (! stream_data.recent_subjects.has(b) && stream_data.recent_subjects.has(a)) {
} else if (! stream_data.is_active(b) && stream_data.is_active(a)) {
return -1;
}
}
@ -120,7 +120,7 @@ exports.build_stream_list = function () {
_.each(pinned_streams, function (stream) {
var li = $(stream_data.get_sub(stream).sidebar_li);
if (sort_recent) {
if (! stream_data.recent_subjects.has(stream)) {
if (! stream_data.is_active(stream)) {
li.addClass('inactive_stream');
} else {
li.removeClass('inactive_stream');