Use underscore in unread.js

(imported from commit 91befaaaff5d9a791a3c1bb4ff99f4085c27c4cb)
This commit is contained in:
Steve Howell 2013-07-26 18:41:19 -04:00
parent 09bd52fff4
commit 3d8ce28964
1 changed files with 6 additions and 6 deletions

View File

@ -64,7 +64,7 @@ exports.update_unread_subjects = function (msg, event) {
}; };
exports.process_loaded_messages = function (messages) { exports.process_loaded_messages = function (messages) {
$.each(messages, function (idx, message) { _.each(messages, function (message) {
var unread = exports.message_unread(message); var unread = exports.message_unread(message);
if (!unread) { if (!unread) {
return; return;
@ -102,7 +102,7 @@ exports.declare_bankruptcy = function () {
exports.num_unread_current_messages = function () { exports.num_unread_current_messages = function () {
var num_unread = 0; var num_unread = 0;
$.each(current_msg_list.all(), function (idx, msg) { _.each(current_msg_list.all(), function (msg) {
if ((msg.id > current_msg_list.selected_id()) && exports.message_unread(msg)) { if ((msg.id > current_msg_list.selected_id()) && exports.message_unread(msg)) {
num_unread += 1; num_unread += 1;
} }
@ -125,12 +125,12 @@ exports.get_counts = function () {
res.pm_count = {}; // Hash by email -> count res.pm_count = {}; // Hash by email -> count
function only_in_home_view(msgids) { function only_in_home_view(msgids) {
return $.grep(msgids, function (msgid) { return _.filter(msgids, function (msgid) {
return home_msg_list.get(msgid) !== undefined; return home_msg_list.get(msgid) !== undefined;
}); });
} }
$.each(unread_counts.stream, function (stream, msgs) { _.each(unread_counts.stream, function (msgs, stream) {
if (! subs.is_subscribed(stream)) { if (! subs.is_subscribed(stream)) {
return true; return true;
} }
@ -144,7 +144,7 @@ exports.get_counts = function () {
if (unread_subjects[stream] !== undefined) { if (unread_subjects[stream] !== undefined) {
res.subject_count[stream] = {}; res.subject_count[stream] = {};
$.each(unread_subjects[stream], function (subject, msgs) { _.each(unread_subjects[stream], function (msgs, subject) {
res.subject_count[stream][subject] = Object.keys(msgs).length; res.subject_count[stream][subject] = Object.keys(msgs).length;
}); });
} }
@ -152,7 +152,7 @@ exports.get_counts = function () {
}); });
var pm_count = 0; var pm_count = 0;
$.each(unread_counts["private"], function (index, obj) { _.each(unread_counts["private"], function (obj, index) {
var count = Object.keys(obj).length; var count = Object.keys(obj).length;
res.pm_count[index] = count; res.pm_count[index] = count;
pm_count += count; pm_count += count;