diff --git a/src/components/PopupSettings/NPEDCategoryPopup.tsx b/src/components/PopupSettings/NPEDCategoryPopup.tsx index 0fa7129..8f5b279 100644 --- a/src/components/PopupSettings/NPEDCategoryPopup.tsx +++ b/src/components/PopupSettings/NPEDCategoryPopup.tsx @@ -30,6 +30,12 @@ const NPEDCategoryPopup = () => { value: values, path: "CategoryPopup", }); + + await mutation.mutateAsync({ + operation: "SAVE", + path: "", + value: null + }) if (result?.reason === "OK") toast.success("Pop up settings saved"); dispatch({ type: "NPEDCATENABLED", payload: values }); }; diff --git a/src/components/SessionForm/SessionCard.tsx b/src/components/SessionForm/SessionCard.tsx index 4d0cab2..d77931b 100644 --- a/src/components/SessionForm/SessionCard.tsx +++ b/src/components/SessionForm/SessionCard.tsx @@ -62,7 +62,11 @@ const SessionCard = () => { path: "sessionStats", value: dedupedSightings, }); - + await mutation.mutateAsync({ + operation: "SAVE", + path: "", + value: null, + }); if (result.reason === "OK") toast.success("Session saved"); }; diff --git a/src/components/SettingForms/Sound/SoundSettingsFields.tsx b/src/components/SettingForms/Sound/SoundSettingsFields.tsx index 5e1a79b..bbd3e93 100644 --- a/src/components/SettingForms/Sound/SoundSettingsFields.tsx +++ b/src/components/SettingForms/Sound/SoundSettingsFields.tsx @@ -39,6 +39,11 @@ const SoundSettingsFields = () => { path: "soundSettings", value: updatedValues, }); + await mutation.mutateAsync({ + operation: "SAVE", + path: "", + value: null, + }); if (result.reason !== "OK") { toast.error("Cannot update sound settings"); } else { diff --git a/src/components/SettingForms/Sound/SoundUpload.tsx b/src/components/SettingForms/Sound/SoundUpload.tsx index 3cd0e6e..4122383 100644 --- a/src/components/SettingForms/Sound/SoundUpload.tsx +++ b/src/components/SettingForms/Sound/SoundUpload.tsx @@ -46,7 +46,11 @@ const SoundUpload = () => { if (result.reason !== "OK") { toast.error("Cannot update sound settings"); } - + await mutation.mutateAsync({ + operation: "SAVE", + path: "", + value: null, + }); dispatch({ type: "ADD", payload: values }); }; diff --git a/src/components/SightingModal/SightingModal.tsx b/src/components/SightingModal/SightingModal.tsx index 428b52c..26a270f 100644 --- a/src/components/SightingModal/SightingModal.tsx +++ b/src/components/SightingModal/SightingModal.tsx @@ -25,7 +25,7 @@ const SightingModal = ({ isSightingModalOpen, handleClose, sighting, onDelete }: const { query, mutation } = useCameraBlackboard(); const hotlistNames = getHotlistName(sighting?.metadata?.hotlistMatches); - const handleAcknowledgeButton = () => { + const handleAcknowledgeButton = async () => { try { if (!sighting) { toast.error("Cannot add sighting to alert list"); @@ -33,17 +33,27 @@ const SightingModal = ({ isSightingModalOpen, handleClose, sighting, onDelete }: return; } if (!query.data.alertHistory) { - mutation.mutate({ + await mutation.mutateAsync({ operation: "INSERT", path: "alertHistory", value: [sighting], }); + await mutation.mutateAsync({ + operation: "SAVE", + path: "", + value: null, + }); } else { - mutation.mutate({ + await mutation.mutateAsync({ operation: "APPEND", path: "alertHistory", value: sighting, }); + await mutation.mutateAsync({ + operation: "SAVE", + path: "", + value: null, + }); toast.success("Sighting Successfully added to alert list"); } diff --git a/src/components/UI/Header.tsx b/src/components/UI/Header.tsx index 7d0f34a..9b8c74a 100644 --- a/src/components/UI/Header.tsx +++ b/src/components/UI/Header.tsx @@ -47,7 +47,7 @@ export default function Header() {
Session Paused
) : ( diff --git a/src/components/UI/SoundBtn.tsx b/src/components/UI/SoundBtn.tsx index 6aaba9f..2802973 100644 --- a/src/components/UI/SoundBtn.tsx +++ b/src/components/UI/SoundBtn.tsx @@ -16,6 +16,11 @@ const SoundBtn = () => { path: "soundEnabled", value: { enabled: newEnabled }, }); + await mutation.mutateAsync({ + operation: "SAVE", + path: "", + value: null, + }); }; useEffect(() => { setEnabled(query?.data?.soundEnabled?.enabled); @@ -23,10 +28,7 @@ const SoundBtn = () => { return ( ); }; diff --git a/src/context/providers/IntegrationsContextProvider.tsx b/src/context/providers/IntegrationsContextProvider.tsx index 4845b2e..b2b3e86 100644 --- a/src/context/providers/IntegrationsContextProvider.tsx +++ b/src/context/providers/IntegrationsContextProvider.tsx @@ -16,6 +16,11 @@ export const IntegrationsProvider = ({ children }: IntegrationsProviderType) => const fetchData = async () => { try { + await mutation.mutateAsync({ + operation: "Load", + path: "", + value: null, + }); const result = await mutation.mutateAsync({ operation: "VIEW", path: "sessionStats", diff --git a/src/context/providers/SoundContextProvider.tsx b/src/context/providers/SoundContextProvider.tsx index f534800..49066a5 100644 --- a/src/context/providers/SoundContextProvider.tsx +++ b/src/context/providers/SoundContextProvider.tsx @@ -20,6 +20,11 @@ const SoundContextProvider = ({ children }: SoundContextProviderProps) => { operation: "VIEW", path: "soundSettings", }); + await mutation.mutateAsync({ + operation: "LOAD", + path: "", + value: null, + }); if (!result.result || typeof result.result !== "object") { dispatch({ type: "UPDATE", payload: state }); diff --git a/src/types/types.ts b/src/types/types.ts index 0c9349a..0f08692 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -282,7 +282,7 @@ export type CameraConfig = { export type CameraBlackBoardOptions = { operation?: string; path?: string; - value?: object | string | number | (string | number)[]; + value?: object | string | number | (string | number)[] | null; }; export type CameraBlackboardResponse = {