From 9db9e6a8930e8d66786b0178f8a11be631e2bb6f Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sun, 19 Apr 2026 12:32:41 -0500 Subject: [PATCH] fix(map): anchor timeline offsets to the Now slot, not wall-clock MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When wall-clock is past :30, the hour *after* Now rounded to "0h" and the Now slot kept its "Now" tag — two adjacent buttons both reading as the current hour. Anchor the offset math to the Now slot itself so the label sequence reads "-1h / Now / +1h / +2h" regardless of where inside the hour the user loaded the page. --- assets/js/propagation_map_hook.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/assets/js/propagation_map_hook.ts b/assets/js/propagation_map_hook.ts index 92fc4535..9d8bd88d 100644 --- a/assets/js/propagation_map_hook.ts +++ b/assets/js/propagation_map_hook.ts @@ -1326,8 +1326,7 @@ export const PropagationMap: Record & { const dt = new Date(t.time) const isSelected = t.time === this.selectedTime const isPast = dt.getTime() < now.getTime() - 1800000 // 30min grace - const offsetH = Math.round((dt.getTime() - now.getTime()) / 3600000) - return { ...t, dt, isSelected, isPast, offsetH, idx, label: "" } + return { ...t, dt, isSelected, isPast, offsetH: 0, idx, label: "" } }) // "Now" = the latest forecast hour at or before wall-clock. Picking @@ -1343,11 +1342,17 @@ export const PropagationMap: Record & { ? items.indexOf(pastOrNow.reduce((latest, t) => t.dt.getTime() > latest.dt.getTime() ? t : latest)) : -1 + // Label offsets relative to the "Now" slot, not wall-clock. If we + // round from wall-clock, the hour after "Now" rounds to "0h" when + // the clock is past the half-hour, which reads as a second "now". + const anchorMs = nowIdx >= 0 ? items[nowIdx].dt.getTime() : nowMs items.forEach((t, i) => { + const diff = Math.round((t.dt.getTime() - anchorMs) / 3600000) + t.offsetH = diff + if (i === nowIdx) { t.label = "Now" } else { - const diff = t.offsetH t.label = diff > 0 ? `+${diff}h` : `${diff}h` } })