From 4a1c24dd75583a1be100dcf45146988027706c08 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Tue, 22 Apr 2025 15:58:22 -0500 Subject: [PATCH] fix notifications --- web/src/components/menu/LiveContextMenu.tsx | 16 ++++++++++++---- .../views/settings/NotificationsSettingsView.tsx | 14 +++++++++++--- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/web/src/components/menu/LiveContextMenu.tsx b/web/src/components/menu/LiveContextMenu.tsx index 5d5bf5028..cfd5fc4b0 100644 --- a/web/src/components/menu/LiveContextMenu.tsx +++ b/web/src/components/menu/LiveContextMenu.tsx @@ -45,6 +45,7 @@ import { useNotificationSuspend, } from "@/api/ws"; import { useTranslation } from "react-i18next"; +import { useDateLocale } from "@/hooks/use-date-locale"; type LiveContextMenuProps = { className?: string; @@ -235,18 +236,25 @@ export default function LiveContextMenu({ } }; + const locale = useDateLocale(); + const formatSuspendedUntil = (timestamp: string) => { // Some languages require a change in word order if (timestamp === "0") return t("time.untilForRestart", { ns: "common" }); - const time = formatUnixTimestampToDateTime(Number.parseInt(timestamp), { + const time = formatUnixTimestampToDateTime(parseInt(timestamp), { time_style: "medium", date_style: "medium", timezone: config?.ui.timezone, - strftime_fmt: + date_format: config?.ui.time_format == "24hour" - ? t("time.formattedTimestampExcludeSeconds.24hour", { ns: "common" }) - : t("time.formattedTimestampExcludeSeconds.12hour", { ns: "common" }), + ? t("time.formattedTimestampMonthDayHourMinute.24hour", { + ns: "common", + }) + : t("time.formattedTimestampMonthDayHourMinute.12hour", { + ns: "common", + }), + locale: locale, }); return t("time.untilForTime", { ns: "common", time }); }; diff --git a/web/src/views/settings/NotificationsSettingsView.tsx b/web/src/views/settings/NotificationsSettingsView.tsx index b30af4336..07274c8ec 100644 --- a/web/src/views/settings/NotificationsSettingsView.tsx +++ b/web/src/views/settings/NotificationsSettingsView.tsx @@ -44,6 +44,7 @@ import { formatUnixTimestampToDateTime } from "@/utils/dateUtil"; import FilterSwitch from "@/components/filter/FilterSwitch"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { Trans, useTranslation } from "react-i18next"; +import { useDateLocale } from "@/hooks/use-date-locale"; const NOTIFICATION_SERVICE_WORKER = "notifications-worker.js"; @@ -645,6 +646,8 @@ export function CameraNotificationSwitch({ sendNotificationSuspend(0); }; + const locale = useDateLocale(); + const formatSuspendedUntil = (timestamp: string) => { // Some languages require a change in word order if (timestamp === "0") return t("time.untilForRestart", { ns: "common" }); @@ -653,10 +656,15 @@ export function CameraNotificationSwitch({ time_style: "medium", date_style: "medium", timezone: config?.ui.timezone, - strftime_fmt: + date_format: config?.ui.time_format == "24hour" - ? t("time.formattedTimestampExcludeSeconds.24hour", { ns: "common" }) - : t("time.formattedTimestampExcludeSeconds.12hour", { ns: "common" }), + ? t("time.formattedTimestampMonthDayHourMinute.24hour", { + ns: "common", + }) + : t("time.formattedTimestampMonthDayHourMinute.12hour", { + ns: "common", + }), + locale: locale, }); return t("time.untilForTime", { ns: "common", time }); };