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