mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-09-27 02:28:58 +03:00
fix notification suspend state lost on page reload (#23989)
<camera>/notifications/suspended arrives as a string over the live connection but as a number in the camera_activity snapshot, and the truthiness guard dropped the numeric 0, so a camera with notifications off rendered as active after a reload. Normalize to a string and derive isSuspended instead of storing it.
This commit is contained in:
+2
-2
@@ -205,7 +205,7 @@ function applyCameraActivity(payload: string) {
|
||||
);
|
||||
applyTopicUpdate(
|
||||
`${name}/notifications/suspended`,
|
||||
notifications_suspended || 0,
|
||||
String(notifications_suspended ?? 0),
|
||||
);
|
||||
applyTopicUpdate(
|
||||
`${name}/ptz_autotracker/state`,
|
||||
@@ -806,7 +806,7 @@ export function useNotificationSuspend(camera: string): {
|
||||
`${camera}/notifications/suspended`,
|
||||
`${camera}/notifications/suspend`,
|
||||
);
|
||||
return { payload: payload as string, send };
|
||||
return { payload: String(payload ?? 0), send };
|
||||
}
|
||||
|
||||
export function useNotificationTest(): {
|
||||
|
||||
@@ -746,18 +746,10 @@ export function CameraNotificationSwitch({
|
||||
useNotifications(camera);
|
||||
const { payload: notificationSuspendUntil, send: sendNotificationSuspend } =
|
||||
useNotificationSuspend(camera);
|
||||
const [isSuspended, setIsSuspended] = useState<boolean>(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (notificationSuspendUntil) {
|
||||
setIsSuspended(
|
||||
notificationSuspendUntil !== "0" || notificationState === "OFF",
|
||||
);
|
||||
}
|
||||
}, [notificationSuspendUntil, notificationState]);
|
||||
const isSuspended =
|
||||
notificationSuspendUntil !== "0" || notificationState === "OFF";
|
||||
|
||||
const handleSuspend = (duration: string) => {
|
||||
setIsSuspended(true);
|
||||
if (duration == "off") {
|
||||
sendNotification("OFF");
|
||||
} else {
|
||||
|
||||
@@ -228,15 +228,8 @@ export default function LiveContextMenu({
|
||||
useNotifications(camera);
|
||||
const { payload: notificationSuspendUntil, send: sendNotificationSuspend } =
|
||||
useNotificationSuspend(camera);
|
||||
const [isSuspended, setIsSuspended] = useState<boolean>(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (notificationSuspendUntil) {
|
||||
setIsSuspended(
|
||||
notificationSuspendUntil !== "0" || notificationState === "OFF",
|
||||
);
|
||||
}
|
||||
}, [notificationSuspendUntil, notificationState]);
|
||||
const isSuspended =
|
||||
notificationSuspendUntil !== "0" || notificationState === "OFF";
|
||||
|
||||
const handleSuspend = (duration: string) => {
|
||||
if (duration === "off") {
|
||||
|
||||
Reference in New Issue
Block a user