Skip to content

Commit

Permalink
vinvoor: add support for new comers
Browse files Browse the repository at this point in the history
  • Loading branch information
Topvennie committed Jul 16, 2024
1 parent bb8a855 commit 3ab6c3d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions vinvoor/src/overview/streak/Streak.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 3ab6c3d

Please sign in to comment.