fix: use date-only timestamp for stable dose IDs (#82)

- Use date-only timestamp instead of full timestamp for dose ID generation
- Ensures changing intake times doesn't invalidate past dose tracking
- IDs are now immune to time configuration changes
This commit is contained in:
Daniel Volz
2026-01-30 19:12:25 +01:00
committed by GitHub
parent aed0b20875
commit 47e8dfe9bc
+4 -1
View File
@@ -29,8 +29,11 @@ export function buildSchedulePreview(
const isPast = d < todayStart;
if (isPast && !includePast) continue;
const whenMs = d.getTime();
// Use date-only timestamp for stable ID (immune to time changes)
// This ensures changing intake times doesn't invalidate past dose tracking
const dateOnlyMs = new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();
events.push({
id: `${med.id}-${idx}-${whenMs}`,
id: `${med.id}-${idx}-${dateOnlyMs}`,
medName: med.name,
takenBy: med.takenBy || [],
usage: blister.usage,