fix notifications

This commit is contained in:
Josh Hawkins 2025-04-22 15:58:22 -05:00
parent f01b4e175e
commit 4a1c24dd75
2 changed files with 23 additions and 7 deletions

View File

@ -45,6 +45,7 @@ import {
useNotificationSuspend, useNotificationSuspend,
} from "@/api/ws"; } from "@/api/ws";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useDateLocale } from "@/hooks/use-date-locale";
type LiveContextMenuProps = { type LiveContextMenuProps = {
className?: string; className?: string;
@ -235,18 +236,25 @@ export default function LiveContextMenu({
} }
}; };
const locale = useDateLocale();
const formatSuspendedUntil = (timestamp: string) => { const formatSuspendedUntil = (timestamp: string) => {
// Some languages require a change in word order // Some languages require a change in word order
if (timestamp === "0") return t("time.untilForRestart", { ns: "common" }); if (timestamp === "0") return t("time.untilForRestart", { ns: "common" });
const time = formatUnixTimestampToDateTime(Number.parseInt(timestamp), { const time = formatUnixTimestampToDateTime(parseInt(timestamp), {
time_style: "medium", time_style: "medium",
date_style: "medium", date_style: "medium",
timezone: config?.ui.timezone, timezone: config?.ui.timezone,
strftime_fmt: date_format:
config?.ui.time_format == "24hour" config?.ui.time_format == "24hour"
? t("time.formattedTimestampExcludeSeconds.24hour", { ns: "common" }) ? t("time.formattedTimestampMonthDayHourMinute.24hour", {
: t("time.formattedTimestampExcludeSeconds.12hour", { ns: "common" }), ns: "common",
})
: t("time.formattedTimestampMonthDayHourMinute.12hour", {
ns: "common",
}),
locale: locale,
}); });
return t("time.untilForTime", { ns: "common", time }); return t("time.untilForTime", { ns: "common", time });
}; };

View File

@ -44,6 +44,7 @@ import { formatUnixTimestampToDateTime } from "@/utils/dateUtil";
import FilterSwitch from "@/components/filter/FilterSwitch"; import FilterSwitch from "@/components/filter/FilterSwitch";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { Trans, useTranslation } from "react-i18next"; import { Trans, useTranslation } from "react-i18next";
import { useDateLocale } from "@/hooks/use-date-locale";
const NOTIFICATION_SERVICE_WORKER = "notifications-worker.js"; const NOTIFICATION_SERVICE_WORKER = "notifications-worker.js";
@ -645,6 +646,8 @@ export function CameraNotificationSwitch({
sendNotificationSuspend(0); sendNotificationSuspend(0);
}; };
const locale = useDateLocale();
const formatSuspendedUntil = (timestamp: string) => { const formatSuspendedUntil = (timestamp: string) => {
// Some languages require a change in word order // Some languages require a change in word order
if (timestamp === "0") return t("time.untilForRestart", { ns: "common" }); if (timestamp === "0") return t("time.untilForRestart", { ns: "common" });
@ -653,10 +656,15 @@ export function CameraNotificationSwitch({
time_style: "medium", time_style: "medium",
date_style: "medium", date_style: "medium",
timezone: config?.ui.timezone, timezone: config?.ui.timezone,
strftime_fmt: date_format:
config?.ui.time_format == "24hour" config?.ui.time_format == "24hour"
? t("time.formattedTimestampExcludeSeconds.24hour", { ns: "common" }) ? t("time.formattedTimestampMonthDayHourMinute.24hour", {
: t("time.formattedTimestampExcludeSeconds.12hour", { ns: "common" }), ns: "common",
})
: t("time.formattedTimestampMonthDayHourMinute.12hour", {
ns: "common",
}),
locale: locale,
}); });
return t("time.untilForTime", { ns: "common", time }); return t("time.untilForTime", { ns: "common", time });
}; };