From 5cff6e3f95adeafbd4b763445f8f4bcb2f0ab4ce Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 4 Feb 2022 11:20:25 -0500 Subject: [PATCH] fix: bug where .reduce() exploded due to no initial value, if input value was an empty array --- src/controllers/accounts/helpers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/accounts/helpers.js b/src/controllers/accounts/helpers.js index 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;