Use new stream_list.set_presence_list_count().

The old API took a dictionary; the new function works for one
person at a time, which allowed us to clean up the calling code
in ui.set_presence_list.

(imported from commit 0ae9d01491238d32915572c7efebf476d05fed4b)
This commit is contained in:
Steve Howell 2013-08-22 15:28:34 -04:00
parent 8d8ea70f5d
commit e4699d6a25
2 changed files with 13 additions and 12 deletions

View File

@ -224,11 +224,8 @@ function animate_mention_changes(new_mention_count) {
}
exports.set_presence_list_counts = function (count_dict) {
// count_dict maps people (emails, actually) to counts
count_dict.each(function (count, person) {
set_count("private", person, count);
});
exports.set_presence_list_count = function (person, count) {
set_count("private", person, count);
};
exports.update_dom_with_unread_counts = function (counts) {
@ -247,7 +244,10 @@ exports.update_dom_with_unread_counts = function (counts) {
});
});
exports.set_presence_list_counts(counts.pm_count);
counts.pm_count.each(function (count, person) {
exports.set_presence_list_count(person, count);
});
// integer counts
set_count("global", "private", counts.private_message_count);

View File

@ -1488,12 +1488,13 @@ exports.set_presence_list = function (users, presence_info) {
if (!suppress_unread_counts) {
// We do this after rendering the template, to avoid dealing with
// the suppress_unread_counts conditional in the template.
var count_dict = new Dict();
_.each(users, function (email) {
count_dict.set(email, unread.num_unread_for_person(email));
});
count_dict.set(page_params.email, unread.num_unread_for_person(page_params.email));
stream_list.set_presence_list_counts(count_dict);
var set_count = function (email) {
stream_list.set_presence_list_count(email, unread.num_unread_for_person(email));
};
_.each(user_emails, set_count);
set_count(page_params.email);
}
};