mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: bug where .reduce() exploded due to no initial value, if input value was an empty array
This commit is contained in:
@@ -170,8 +170,8 @@ async function getCounts(userData, callerUID) {
|
|||||||
promises.blocks = user.getUserField(userData.uid, 'blocksCount');
|
promises.blocks = user.getUserField(userData.uid, 'blocksCount');
|
||||||
}
|
}
|
||||||
const counts = await utils.promiseParallel(promises);
|
const counts = await utils.promiseParallel(promises);
|
||||||
counts.best = counts.best.reduce((sum, count) => sum + count);
|
counts.best = counts.best.reduce((sum, count) => sum + count, 0);
|
||||||
counts.controversial = counts.controversial.reduce((sum, count) => sum + count);
|
counts.controversial = counts.controversial.reduce((sum, count) => sum + count, 0);
|
||||||
counts.categoriesWatched = counts.categoriesWatched && counts.categoriesWatched.length;
|
counts.categoriesWatched = counts.categoriesWatched && counts.categoriesWatched.length;
|
||||||
counts.groups = userData.groups.length;
|
counts.groups = userData.groups.length;
|
||||||
counts.following = userData.followingCount;
|
counts.following = userData.followingCount;
|
||||||
|
|||||||
Reference in New Issue
Block a user