2025-09-30 14:51:37 +01:00
|
|
|
import { createContext, useContext, type Dispatch } from "react";
|
2025-10-01 15:21:07 +01:00
|
|
|
import type { SoundAction, SoundState } from "../types/types";
|
2025-09-30 14:51:37 +01:00
|
|
|
|
|
|
|
|
type SoundContextType = {
|
|
|
|
|
state: SoundState;
|
2025-10-01 15:21:07 +01:00
|
|
|
dispatch: Dispatch<SoundAction>;
|
2025-10-15 11:00:52 +01:00
|
|
|
audioArmed: boolean;
|
2025-09-30 14:51:37 +01:00
|
|
|
};
|
|
|
|
|
|
2025-10-17 16:12:02 +01:00
|
|
|
export const SoundContext = createContext<SoundContextType | undefined>(undefined);
|
2025-09-30 14:51:37 +01:00
|
|
|
|
|
|
|
|
export const useSoundContext = () => {
|
|
|
|
|
const ctx = useContext(SoundContext);
|
2025-10-17 16:12:02 +01:00
|
|
|
if (!ctx) throw new Error("useSoundContext must be used within <SoundContext>");
|
2025-09-30 14:51:37 +01:00
|
|
|
return ctx;
|
|
|
|
|
};
|