Node.js based forum software built for the modern web
fix: bug where .reduce() exploded due to no initial value, if input value was an empty array
Julian Lam5cff6e3f95ad
diff --git a/src/controllers/accounts/helpers.js b/src/controllers/accounts/helpers.jsindex 12d82144e5..d845ebdbb0 100644--- a/src/controllers/accounts/helpers.js+++ b/src/controllers/accounts/helpers.js@@ -170,8 +170,8 @@ async function getCounts(userData, callerUID) {promises.blocks = user.getUserField(userData.uid, 'blocksCount');}const counts = await utils.promiseParallel(promises);- counts.best = counts.best.reduce((sum, count) => sum + count);- counts.controversial = counts.controversial.reduce((sum, count) => sum + count);+ counts.best = counts.best.reduce((sum, count) => sum + count, 0);+ counts.controversial = counts.controversial.reduce((sum, count) => sum + count, 0);counts.categoriesWatched = counts.categoriesWatched && counts.categoriesWatched.length;counts.groups = userData.groups.length;counts.following = userData.followingCount;