fix: address widget reload review findings
This commit is contained in:
10 files changed
+206
-29
No files matched your search
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user