fix: bug where .reduce() exploded due to no initial value, if input value was an empty array

isekai-main
Julian Lam 3 years ago
parent 5afd5de07d
commit 5cff6e3f95

@ -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;

Loading…
Cancel
Save