From bac1f161508759de9805b4acab07530622c21ffe Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 22 Aug 2026 08:58:32 +0000 Subject: [PATCH] Only call the map "live" on today's date For past dates the menu tile and page nav now just say "Map" / "See this day on the map" instead of "Live tracking map" / "Follow along on the map", since there's nothing live about a historic day. --- website/app/components/DatePageNav.tsx | 4 +++- website/app/routes/date/index.tsx | 9 ++++++--- website/app/utils/dateTime.ts | 7 +++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/website/app/components/DatePageNav.tsx b/website/app/components/DatePageNav.tsx index 9a57394..cdb0e7b 100644 --- a/website/app/components/DatePageNav.tsx +++ b/website/app/components/DatePageNav.tsx @@ -1,5 +1,6 @@ import { Button, Group } from "@mantine/core"; import { Link } from "react-router"; +import { isTodayUtcDay } from "~/utils/dateTime"; /** * `historic` has no button of its own — the comparison page is reached from the menu — but @@ -31,6 +32,7 @@ const PAGES: Array<{ page: DatePage; label: string; path: string }> = [ export function DatePageNav({ password, urlDate, current }: DatePageNavProps) { const basePath = `/${password}/${urlDate}`; + const isToday = isTodayUtcDay(urlDate); return ( @@ -42,7 +44,7 @@ export function DatePageNav({ password, urlDate, current }: DatePageNavProps) { variant={current === page ? "filled" : "light"} size="compact-md" > - {label} + {page === "live" && !isToday ? "Map" : label} ))} diff --git a/website/app/routes/date/index.tsx b/website/app/routes/date/index.tsx index bf740a0..17d60b2 100644 --- a/website/app/routes/date/index.tsx +++ b/website/app/routes/date/index.tsx @@ -15,7 +15,7 @@ import { import { Link, type MetaFunction } from "react-router"; import * as Schema from "~/database/schema.d"; import { getDb, getPasswordRouteAccess } from "~/routeContext"; -import { formatUtcDay } from "~/utils/dateTime"; +import { formatUtcDay, isTodayUtcDay } from "~/utils/dateTime"; import type { Route } from "./+types/index"; import { IconAntennaBars5, @@ -56,6 +56,7 @@ export async function loader({ context }: Route.LoaderArgs) { export default function Page({ loaderData }: Route.ComponentProps) { const theme = useMantineTheme(); + const isToday = isTodayUtcDay(loaderData.urlDate); if (!loaderData.hasData) { return ( @@ -97,9 +98,11 @@ export default function Page({ loaderData }: Route.ComponentProps) { >
- Live tracking map + {isToday ? "Live tracking map" : "Map"} - Follow along on the map + {isToday + ? "Follow along on the map" + : "See this day on the map"}
diff --git a/website/app/utils/dateTime.ts b/website/app/utils/dateTime.ts index c255020..04e202a 100644 --- a/website/app/utils/dateTime.ts +++ b/website/app/utils/dateTime.ts @@ -66,6 +66,13 @@ export const formatDateTimeWithSeconds = (rawTimestamp: number) => */ export const formatUtcDay = (dayString: string) => dayString; +/** Today's UTC day bucket, in the same `YYYY-MM-DD` form as `events.date_string`. */ +export const todayUtcDay = () => DateTime.now().toUTC().toFormat("yyyy-MM-dd"); + +/** Whether a `YYYY-MM-DD` UTC day bucket is today. */ +export const isTodayUtcDay = (dayString: string) => + dayString === todayUtcDay(); + /** * A human duration between two stored timestamps, e.g. `2h 14m`, `47m`, `35s`. *