From a32221462dbf3ae1de97de95059a1042a0fb398f Mon Sep 17 00:00:00 2001 From: richardscull <106016833+richardscull@users.noreply.github.com> Date: Sat, 28 Feb 2026 10:48:24 +0200 Subject: [PATCH] fix: iterate through all snapshots --- app/(website)/user/[id]/components/UserStatsChart.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/(website)/user/[id]/components/UserStatsChart.tsx b/app/(website)/user/[id]/components/UserStatsChart.tsx index e03e29f..414e36f 100644 --- a/app/(website)/user/[id]/components/UserStatsChart.tsx +++ b/app/(website)/user/[id]/components/UserStatsChart.tsx @@ -56,16 +56,18 @@ export default function UserStatsChart({ data, value: chartValue }: Props) { const currentDateStr = currentDate.toDateString(); let snapshotForThisDay: StatsSnapshotResponse | null = null; - if (snapshotIndex < snapshots.length) { + while (snapshotIndex < snapshots.length) { const snapshotDate = new Date(snapshots[snapshotIndex].saved_at); snapshotDate.setHours(0, 0, 0, 0); - const snapshotDateStr = snapshotDate.toDateString(); - if (currentDateStr === snapshotDateStr) { + if (currentDateStr === snapshotDate.toDateString()) { snapshotForThisDay = snapshots[snapshotIndex]; lastValidSnapshot = { ...snapshots[snapshotIndex] }; snapshotIndex++; } + else { + break; + } } if (snapshotForThisDay) {