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

@@ -14,7 +14,7 @@ function unread_hashkey(message) {
if (message.type === 'stream') {
hashkey = subs.canonicalized_name(message.stream);
} else {
hashkey = message.display_reply_to;
hashkey = message.reply_to;
}
if (unread_counts[message.type][hashkey] === undefined) {
@@ -121,6 +121,7 @@ exports.get_counts = function () {
res.mentioned_message_count = Object.keys(unread_mentioned).length;
res.stream_count = {}; // hash by stream -> count
res.subject_count = {}; // hash of hashes (stream, then subject -> count)
res.pm_count = {}; // Hash by email -> count
function only_in_home_view(msgids) {
return $.grep(msgids, function (msgid) {
@@ -134,7 +135,7 @@ exports.get_counts = function () {
}
var count = Object.keys(msgs).length;
res.stream_count[stream]= count;
res.stream_count[stream] = count;
if (narrow.stream_in_home(stream)) {
res.home_unread_messages += only_in_home_view(Object.keys(msgs)).length;
@@ -151,7 +152,9 @@ exports.get_counts = function () {
var pm_count = 0;
$.each(unread_counts["private"], function(index, obj) {
pm_count += Object.keys(obj).length;
var count = Object.keys(obj).length;
res.pm_count[index] = count;
pm_count += count;
});
res.private_message_count = pm_count;
res.home_unread_messages += pm_count;