When already viewing today, clicking Today now snaps the selected hour to whatever hour would be default for the current wall-clock time (same as a fresh visit to /vu); when viewing another date it still just jumps to today while preserving the current hour, as before. The link's href is built from the same todayTargetHour() decision as the click handler, so right-click -> open in new tab lands on the same target instead of following a stale href. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CbHcmjnqQPJZ1i2yoebmp5
This commit is contained in:
+18
-1
@@ -56,8 +56,25 @@ export function setDate(date: string): void {
|
||||
notify();
|
||||
}
|
||||
|
||||
/**
|
||||
* Which hour the "Today" link should point to: if we're already viewing
|
||||
* today, the current time-of-day default (as if freshly visiting `/vu`
|
||||
* right now); otherwise the hour currently selected, unchanged. Shared by
|
||||
* `goToToday()` and the link's `href` (`day-nav.ts`) so a plain click and
|
||||
* a right-click-open-in-new-tab land on the same target.
|
||||
*/
|
||||
export function todayTargetHour(): HourId {
|
||||
return state.date === todayIso() ? defaultHourForTime(new Date()) : state.selectedHour;
|
||||
}
|
||||
|
||||
export function goToToday(): void {
|
||||
setDate(todayIso());
|
||||
const today = todayIso();
|
||||
const hour = todayTargetHour();
|
||||
if (state.date === today) {
|
||||
setSelectedHour(hour);
|
||||
} else {
|
||||
setDate(today);
|
||||
}
|
||||
}
|
||||
|
||||
export function addDays(date: string, days: number): string {
|
||||
|
||||
Reference in New Issue
Block a user