2025-10-01 15:21:07 +01:00
|
|
|
import type { SoundAction, SoundState } from "../../types/types";
|
2025-09-30 14:51:37 +01:00
|
|
|
|
2025-10-01 15:21:07 +01:00
|
|
|
export const initialState: SoundState = {
|
2025-09-30 14:51:37 +01:00
|
|
|
sightingSound: "switch",
|
|
|
|
|
NPEDsound: "popup",
|
|
|
|
|
hotlists: [],
|
2025-10-01 15:21:07 +01:00
|
|
|
soundOptions: [
|
|
|
|
|
{ name: "switch (Default)", soundFile: null },
|
|
|
|
|
{ name: "popup", soundFile: null },
|
|
|
|
|
{ name: "notification", soundFile: null },
|
|
|
|
|
],
|
2025-09-30 14:51:37 +01:00
|
|
|
};
|
|
|
|
|
|
2025-10-01 15:21:07 +01:00
|
|
|
export function reducer(state: SoundState, action: SoundAction): SoundState {
|
2025-09-30 14:51:37 +01:00
|
|
|
switch (action.type) {
|
2025-10-01 15:21:07 +01:00
|
|
|
case "UPDATE": {
|
2025-09-30 14:51:37 +01:00
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
sightingSound: action.payload.sightingSound,
|
|
|
|
|
NPEDsound: action.payload.NPEDsound,
|
2025-09-30 15:32:00 +01:00
|
|
|
hotlists: action.payload.hotlists.map((hotlist) => ({
|
|
|
|
|
name: hotlist.name,
|
|
|
|
|
sound: hotlist.sound,
|
|
|
|
|
})),
|
2025-09-30 14:51:37 +01:00
|
|
|
};
|
2025-10-01 15:21:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "ADD": {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
soundOptions: [...(state.soundOptions ?? []), action.payload],
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return state;
|
2025-09-30 14:51:37 +01:00
|
|
|
}
|
|
|
|
|
}
|