- added state to set sound set settings for sightings and NPED hits

- added function to save mute settings
This commit is contained in:
2025-10-08 11:08:41 +01:00
parent a20a0c7019
commit 40909d48b6
8 changed files with 59 additions and 17 deletions

View File

@@ -1,6 +1,7 @@
import { useMemo, useReducer, type ReactNode } from "react";
import { useEffect, useMemo, useReducer, type ReactNode } from "react";
import { SoundContext } from "../SoundContext";
import { initialState, reducer } from "../reducers/SoundContextReducer";
import { useCameraBlackboard } from "../../hooks/useCameraBlackboard";
type SoundContextProviderProps = {
children: ReactNode;
@@ -8,6 +9,20 @@ type SoundContextProviderProps = {
const SoundContextProvider = ({ children }: SoundContextProviderProps) => {
const [state, dispatch] = useReducer(reducer, initialState);
const { mutation } = useCameraBlackboard();
useEffect(() => {
const fetchSound = async () => {
const result = await mutation.mutateAsync({
operation: "VIEW",
path: "soundSettings",
});
dispatch({ type: "UPDATE", payload: result.result });
};
fetchSound();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const value = useMemo(() => ({ state, dispatch }), [state, dispatch]);
return (
<SoundContext.Provider value={value}>{children}</SoundContext.Provider>