fix: address widget reload review findings

This commit is contained in:
Thomas Camlong committed 2026-08-23 09:00:33 +02:00
1 parent 357355283c
commit 65a96b6b14
10 files changed
+206 -29

No files matched your search

+5 -1
View File
@@ -4,6 +4,7 @@ import { Box, Center, Stack, Text, Title } from "@mantine/core";
import dayjs from "dayjs";
import advancedFormat from "dayjs/plugin/advancedFormat";
import { useWidgetLocalTimeZone } from "../common/widget-time-context";
import type { WidgetComponentProps } from "../definition";
import { AdvancedClockView } from "./advanced-view";
import { clockTimeFormatShowsSeconds, resolveClockTimeFormat } from "./format";
@@ -17,7 +18,10 @@ export default function ClockWidget({ options, width, height, displayMode }: Wid
const isAdvanced = displayMode === "advanced";
const showSeconds = clockTimeFormatShowsSeconds(options.customTimeFormat);
const time = useCurrentTime({ showSeconds });
const requestedTimeZone = options.useCustomTimezone ? options.timezone : getResolvedLocalTimeZone();
const initialLocalTimeZone = useWidgetLocalTimeZone();
const requestedTimeZone = options.useCustomTimezone
? options.timezone
: (initialLocalTimeZone ?? getResolvedLocalTimeZone());
const primaryTimeZoneInvalid = !isTimeZoneSupported(requestedTimeZone);
const primaryTimeZone = primaryTimeZoneInvalid ? "UTC" : requestedTimeZone;
const zonedTime = time === null ? null : dayjs(time).tz(primaryTimeZone);