mirror of
https://github.com/zulip/zulip.git
synced 2025-11-18 04:43:58 +00:00
Use d.each() for iterating Dict instances.
(imported from commit 8cfe2c9a61aa1179454a6ab986fa23d04de09525)
This commit is contained in:
@@ -228,27 +228,19 @@ exports.update_dom_with_unread_counts = function (counts) {
|
|||||||
// Our job is to update some DOM elements.
|
// Our job is to update some DOM elements.
|
||||||
|
|
||||||
// counts.stream_count maps streams to counts
|
// counts.stream_count maps streams to counts
|
||||||
_.each(counts.stream_count.items(), function (item) {
|
counts.stream_count.each(function (count, stream) {
|
||||||
var stream = item[0];
|
|
||||||
var count = item[1];
|
|
||||||
exports.set_count("stream", stream, count);
|
exports.set_count("stream", stream, count);
|
||||||
});
|
});
|
||||||
|
|
||||||
// counts.subject_count maps streams to hashes of subjects to counts
|
// counts.subject_count maps streams to hashes of subjects to counts
|
||||||
_.each(counts.subject_count.items(), function (item) {
|
counts.subject_count.each(function (subject_hash, stream) {
|
||||||
var stream = item[0];
|
subject_hash.each(function (count, subject) {
|
||||||
var subject_hash = item[1];
|
|
||||||
_.each(subject_hash.items(), function (item) {
|
|
||||||
var subject = item[0];
|
|
||||||
var count = item[1];
|
|
||||||
exports.set_subject_count(stream, subject, count);
|
exports.set_subject_count(stream, subject, count);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// counts.pm_count maps people to counts
|
// counts.pm_count maps people to counts
|
||||||
_.each(counts.pm_count.items(), function (item) {
|
counts.pm_count.each(function (count, person) {
|
||||||
var person = item[0];
|
|
||||||
var count = item[1];
|
|
||||||
exports.set_count("private", person, count);
|
exports.set_count("private", person, count);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -130,9 +130,7 @@ exports.get_counts = function () {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_.each(unread_counts.stream.items(), function (item) {
|
unread_counts.stream.each(function (msgs, stream) {
|
||||||
var stream = item[0];
|
|
||||||
var msgs = item[1];
|
|
||||||
if (! subs.is_subscribed(stream)) {
|
if (! subs.is_subscribed(stream)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -146,9 +144,7 @@ exports.get_counts = function () {
|
|||||||
|
|
||||||
if (unread_subjects.has(stream)) {
|
if (unread_subjects.has(stream)) {
|
||||||
res.subject_count.set(stream, new Dict());
|
res.subject_count.set(stream, new Dict());
|
||||||
_.each(unread_subjects.get(stream).items(), function (item) {
|
unread_subjects.get(stream).each(function (msgs, subject) {
|
||||||
var subject = item[0];
|
|
||||||
var msgs = item[1];
|
|
||||||
res.subject_count.get(stream).set(subject, Object.keys(msgs).length);
|
res.subject_count.get(stream).set(subject, Object.keys(msgs).length);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -156,9 +152,7 @@ exports.get_counts = function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var pm_count = 0;
|
var pm_count = 0;
|
||||||
_.each(unread_counts["private"].items(), function (item) {
|
unread_counts["private"].each(function (obj, index) {
|
||||||
var index = item[0];
|
|
||||||
var obj = item[1];
|
|
||||||
var count = Object.keys(obj).length;
|
var count = Object.keys(obj).length;
|
||||||
res.pm_count.set(index, count);
|
res.pm_count.set(index, count);
|
||||||
pm_count += count;
|
pm_count += count;
|
||||||
|
|||||||
Reference in New Issue
Block a user