Add unread counts to the user sidebar.

Because of spacing issues in the right sidebar, the unread counts
appear to the left of the person's name, not the right.

It's kinda awesome that this is only 20 lines of code.

(imported from commit f5a4ea27bc4cd2e8157746ce7524a600b638930b)
This commit is contained in:
Tim Abbott
2013-06-05 14:29:31 -04:00
parent 8884e81bb3
commit a2a696dacf
4 changed files with 20 additions and 4 deletions

View File

@@ -65,9 +65,13 @@ function iterate_to_find(selector, data_name, context) {
return retval;
}
// TODO: Now that the unread count functions support the user sidebar
// as well, we probably should consider moving them to a different file.
function get_filter_li(type, name) {
if (type === 'stream') {
return $("#stream_sidebar_" + subs.stream_id(name));
} else if (type === "private") {
return $(".user_sidebar_entry > a[data-email='" + name + "']");
}
return iterate_to_find("#" + type + "_filters > li", name);
}
@@ -224,6 +228,11 @@ exports.update_dom_with_unread_counts = function (counts) {
});
});
// counts.pm_count maps people to counts
$.each(counts.pm_count, function(person, count) {
exports.set_count("private", person, count);
});
// integer counts
exports.set_count("global", "private-message", counts.private_message_count);
exports.set_count("global", "mentioned-message", counts.mentioned_message_count);