From cd403fe60578ff5be3b5977e8b3d8bf1c0ec5e78 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Fri, 13 Oct 2023 15:31:04 +0800 Subject: [PATCH] Fix error with zero posts --- src/components/account-info.jsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/account-info.jsx b/src/components/account-info.jsx index 45ffc3be..2f8e60fc 100644 --- a/src/components/account-info.jsx +++ b/src/components/account-info.jsx @@ -102,9 +102,12 @@ async function fetchPostingStats(accountID, masto) { }); // Count days since last post - stats.daysSinceLastPost = Math.ceil( - (Date.now() - new Date(statuses[statuses.length - 1].createdAt)) / 86400000, - ); + if (statuses.length) { + stats.daysSinceLastPost = Math.ceil( + (Date.now() - new Date(statuses[statuses.length - 1].createdAt)) / + 86400000, + ); + } console.log('posting stats', stats); return stats;