mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
js: Convert _.reduce to less convoluted code.
reduce is almost never a better solution than the alternatives. Avoid it. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
committed by
Tim Abbott
parent
050915c46c
commit
e1cf5e4630
@@ -93,7 +93,8 @@ exports.create = function ($container, list, opts) {
|
||||
const slice = meta.filtered_list.slice(meta.offset, meta.offset + load_count);
|
||||
|
||||
const finish = blueslip.start_timing('list_render ' + opts.name);
|
||||
const html = _.reduce(slice, function (acc, item) {
|
||||
let html = "";
|
||||
for (const item of slice) {
|
||||
let _item = opts.modifier(item);
|
||||
|
||||
// if valid jQuery selection, attempt to grab all elements within
|
||||
@@ -116,9 +117,9 @@ exports.create = function ($container, list, opts) {
|
||||
_item = _item.outerHTML;
|
||||
}
|
||||
|
||||
// return the modified HTML or nothing if corrupt (null, undef, etc.).
|
||||
return acc + (_item || "");
|
||||
}, "");
|
||||
// append the HTML or nothing if corrupt (null, undef, etc.).
|
||||
html += _item || "";
|
||||
}
|
||||
|
||||
finish();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user