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:
@@ -29,8 +29,11 @@ export function buildSchedulePreview(
|
|||||||
const isPast = d < todayStart;
|
const isPast = d < todayStart;
|
||||||
if (isPast && !includePast) continue;
|
if (isPast && !includePast) continue;
|
||||||
const whenMs = d.getTime();
|
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({
|
events.push({
|
||||||
id: `${med.id}-${idx}-${whenMs}`,
|
id: `${med.id}-${idx}-${dateOnlyMs}`,
|
||||||
medName: med.name,
|
medName: med.name,
|
||||||
takenBy: med.takenBy || [],
|
takenBy: med.takenBy || [],
|
||||||
usage: blister.usage,
|
usage: blister.usage,
|
||||||
|
|||||||
Reference in New Issue
Block a user