Files
Mav-Mobile-UI/src/context/reducers/SoundContextReducer.ts

43 lines
1.1 KiB
TypeScript
Raw Normal View History

import type { SoundAction, SoundState } from "../../types/types";
export const initialState: SoundState = {
sightingSound: "switch",
NPEDsound: "popup",
hotlists: [{ name: "hotlistName", sound: "notification" }],
soundOptions: [
2025-10-17 10:17:01 +01:00
{ name: "Switch (Default)", soundFile: "switch" },
{ name: "Popup", soundFile: "popup" },
{ name: "Notification", soundFile: "notification" },
{ name: "Beep", soundFile: "beep" },
{ name: "Ding", soundFile: "ding" },
{ name: "Shutter", soundFile: "shutter" },
{ name: "Warning (voice)", soundFile: "warning" },
],
};
export function reducer(state: SoundState, action: SoundAction): SoundState {
switch (action.type) {
case "UPDATE": {
return {
...state,
sightingSound: action.payload.sightingSound,
NPEDsound: action.payload.NPEDsound,
hotlists: action.payload.hotlists?.map((hotlist) => ({
name: hotlist.name,
sound: hotlist.sound,
})),
};
}
case "ADD": {
return {
...state,
soundOptions: [...(state.soundOptions ?? []), action.payload],
};
}
default:
return state;
}
}