- got to a good place on individual hotlist sounds
This commit is contained in:
@@ -5,6 +5,7 @@ export const initialState: SoundState = {
|
||||
NPEDsound: "popup",
|
||||
hotlistSound: "warning",
|
||||
hotlists: [{ name: "hotlistName", sound: "notification" }],
|
||||
hotlistSoundMap: new Map<string, string>(),
|
||||
soundOptions: [
|
||||
{ name: "Switch (Default)", soundFileName: "switch" },
|
||||
{ name: "Popup", soundFileName: "popup" },
|
||||
@@ -24,19 +25,23 @@ export const initialState: SoundState = {
|
||||
export function reducer(state: SoundState, action: SoundAction): SoundState {
|
||||
switch (action.type) {
|
||||
case "UPDATE": {
|
||||
const nextHotlistSoundMap = new Map<string, string>();
|
||||
if (action.payload.hotlistSoundMap) {
|
||||
for (const [key, value] of Object.entries(action.payload.hotlistSoundMap)) {
|
||||
nextHotlistSoundMap.set(key, value);
|
||||
}
|
||||
}
|
||||
return {
|
||||
...state,
|
||||
sightingSound: action.payload.sightingSound,
|
||||
NPEDsound: action.payload.NPEDsound,
|
||||
hotlistSound: action.payload.hotlistSound,
|
||||
hotlists: action.payload.hotlists?.map((hotlist) => ({
|
||||
name: hotlist.name,
|
||||
sound: hotlist.sound,
|
||||
})),
|
||||
NPEDsoundVolume: action.payload.NPEDsoundVolume,
|
||||
sightingVolume: action.payload.sightingVolume,
|
||||
hotlistSoundVolume: action.payload.hotlistSoundVolume,
|
||||
soundOptions: action.payload.soundOptions,
|
||||
hotlists: action.payload.hotlists,
|
||||
hotlistSoundMap: nextHotlistSoundMap,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -69,6 +74,16 @@ export function reducer(state: SoundState, action: SoundAction): SoundState {
|
||||
...state,
|
||||
uploadedSound: action.payload,
|
||||
};
|
||||
case "SETHOTLISTS":
|
||||
return {
|
||||
...state,
|
||||
hotlists: action.payload,
|
||||
};
|
||||
case "SETHOTLISTSOUNDMAP":
|
||||
return {
|
||||
...state,
|
||||
hotlistSoundMap: action.payload,
|
||||
};
|
||||
case "RESET":
|
||||
return initialState;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user