Refactor sound context and update sound settings functionality; remove console logs and improve sound file handling
This commit is contained in:
@@ -1,14 +1,19 @@
|
||||
import type { SoundPayload, SoundState } from "../../types/types";
|
||||
import type { SoundAction, SoundState } from "../../types/types";
|
||||
|
||||
export const initalState: SoundState = {
|
||||
export const initialState: SoundState = {
|
||||
sightingSound: "switch",
|
||||
NPEDsound: "popup",
|
||||
hotlists: [],
|
||||
soundOptions: [
|
||||
{ name: "switch (Default)", soundFile: null },
|
||||
{ name: "popup", soundFile: null },
|
||||
{ name: "notification", soundFile: null },
|
||||
],
|
||||
};
|
||||
|
||||
export function reducer(state: SoundState, action: SoundPayload) {
|
||||
export function reducer(state: SoundState, action: SoundAction): SoundState {
|
||||
switch (action.type) {
|
||||
case "UPDATE":
|
||||
case "UPDATE": {
|
||||
return {
|
||||
...state,
|
||||
sightingSound: action.payload.sightingSound,
|
||||
@@ -18,6 +23,16 @@ export function reducer(state: SoundState, action: SoundPayload) {
|
||||
sound: hotlist.sound,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
case "ADD": {
|
||||
return {
|
||||
...state,
|
||||
soundOptions: [...(state.soundOptions ?? []), action.payload],
|
||||
};
|
||||
}
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user