Unify calculation of unread-count for notifications and use it in the title bar

Fixes trac #1004

(imported from commit 6f04d1d3ded198b46cc2ff1733b94b5c17beb581)
This commit is contained in:
Leo Franchi
2013-03-19 16:53:49 -04:00
parent 02554b28cb
commit 6263c9ba1e
5 changed files with 60 additions and 63 deletions

View File

@@ -192,6 +192,20 @@ function send_queued_flags() {
var unread_counts = {'stream': {}, 'private': {}};
var home_unread_messages = 0;
function unread_in_current_view() {
var unread = 0;
if (!narrow.active()) {
unread = home_unread_messages;
} else {
$.each(current_msg_list.all(), function (idx, msg) {
if (message_unread(msg) && msg.id > current_msg_list.selected_id()) {
unread += 1;
}
});
}
return unread;
}
function message_unread(message) {
if (message === undefined) {
return false;