From 8fe8f9d417e75126c30e6c8f3da4aacd9799f905 Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Wed, 15 Jul 2026 13:26:30 +0000 Subject: [PATCH] Log training sessions onto the selected day, not always today The Log button stamps the selected day at the current time of day, so a forgotten session can be back-filled from that day's view. The snackbar says which day it landed on when it isn't today; Undo/Add note still work on it. --- src/app.js | 15 +++++++++++++-- src/changelog.json | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/app.js b/src/app.js index 509e8b0..f971181 100644 --- a/src/app.js +++ b/src/app.js @@ -1711,8 +1711,19 @@ logBtn.textContent = "Log"; logBtn.addEventListener("click", (e) => { e.stopPropagation(); - const ev = addEvent("training", "", Date.now(), { exerciseId: ex.id }); - showSnackbar(`${ex.name} logged`, ev); + // Log onto the selected day (at the current time of day), so a session + // that was forgotten yesterday can be back-filled from that day's view. + const day = selectedDay(); + const onToday = ymd(day) === ymd(new Date()); + let at = Date.now(); + if (!onToday) { + const now = new Date(); + at = new Date(day.getFullYear(), day.getMonth(), day.getDate(), + now.getHours(), now.getMinutes(), now.getSeconds()).getTime(); + } + const ev = addEvent("training", "", at, { exerciseId: ex.id }); + const dayStr = day.toLocaleDateString(undefined, { month: "short", day: "numeric" }); + showSnackbar(onToday ? `${ex.name} logged` : `${ex.name} logged for ${dayStr}`, ev); }); row.appendChild(main); diff --git a/src/changelog.json b/src/changelog.json index e12458d..4bf701c 100644 --- a/src/changelog.json +++ b/src/changelog.json @@ -1,4 +1,5 @@ [ + { "date": "2026-07-15", "text": "Logging a training session while viewing another day puts it on that day (the snackbar tells you where it went)" }, { "date": "2026-07-15", "text": "The Sleep trend yesterday line is orange instead of gray, which was hard to see" }, { "date": "2026-07-15", "text": "The Sleep trend average line is teal now, so it doesn't blend in with today's blue line and its projection" }, { "date": "2026-07-15", "text": "Tapping a day in a chart selects it without jumping down to the history" },