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.
This commit is contained in:
Alexander Heldt
2026-07-15 13:26:30 +00:00
parent c24d59e672
commit 8fe8f9d417
2 changed files with 14 additions and 2 deletions
+13 -2
View File
@@ -1711,8 +1711,19 @@
logBtn.textContent = "Log"; logBtn.textContent = "Log";
logBtn.addEventListener("click", (e) => { logBtn.addEventListener("click", (e) => {
e.stopPropagation(); e.stopPropagation();
const ev = addEvent("training", "", Date.now(), { exerciseId: ex.id }); // Log onto the selected day (at the current time of day), so a session
showSnackbar(`${ex.name} logged`, ev); // 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); row.appendChild(main);
+1
View File
@@ -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 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": "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" }, { "date": "2026-07-15", "text": "Tapping a day in a chart selects it without jumping down to the history" },