Refactor sound context and update sound settings functionality; remove console logs and improve sound file handling

This commit is contained in:
2025-10-01 15:21:07 +01:00
parent 1b7b2eec37
commit 68e944a6a2
11 changed files with 100 additions and 53 deletions

View File

@@ -1,17 +1,16 @@
import { useReducer, type ReactNode } from "react";
import { useMemo, useReducer, type ReactNode } from "react";
import { SoundContext } from "../SoundContext";
import { initalState, reducer } from "../reducers/SoundContextReducer";
import { initialState, reducer } from "../reducers/SoundContextReducer";
type SoundContextProviderProps = {
children: ReactNode;
};
const SoundContextProvider = ({ children }: SoundContextProviderProps) => {
const [state, dispatch] = useReducer(reducer, initalState);
const [state, dispatch] = useReducer(reducer, initialState);
const value = useMemo(() => ({ state, dispatch }), [state, dispatch]);
return (
<SoundContext.Provider value={{ state, dispatch }}>
{children}
</SoundContext.Provider>
<SoundContext.Provider value={value}>{children}</SoundContext.Provider>
);
};