From 3ab6c3d1218ce804bdb91ae95945ac376daf1432 Mon Sep 17 00:00:00 2001 From: Topvennie Date: Tue, 16 Jul 2024 21:51:55 +0200 Subject: [PATCH] vinvoor: add support for new comers --- vinvoor/src/overview/streak/Streak.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/vinvoor/src/overview/streak/Streak.tsx b/vinvoor/src/overview/streak/Streak.tsx index e2dffeb..2f09037 100644 --- a/vinvoor/src/overview/streak/Streak.tsx +++ b/vinvoor/src/overview/streak/Streak.tsx @@ -41,12 +41,15 @@ const getStreak = (scans: readonly Scan[]): [boolean, number] => { while (i-- > 1 && isStreakDay(scans[i].scanTime, scans[i - 1].scanTime)) streak++; } else { - streak = Math.floor( - (new Date().getTime() - - scans[scans.length - 1].scanTime.getTime()) / - MILLISECONDS_IN_ONE_DAY - - 1 - ); + streak = + scans.length > 0 + ? Math.floor( + (new Date().getTime() - + scans[scans.length - 1].scanTime.getTime()) / + MILLISECONDS_IN_ONE_DAY - + 1 + ) + : 0; } return [isOnStreak, streak];