fcc-challenges/drum-machine-react/src/reducers/volumeOffSetsReducer.js

22 lines
437 B
JavaScript

import { padsArray,initialPadVolumes } from "../Globals";
const getVolumeOffSets = () => {
const volumeOffSets = {};
padsArray.forEach(key => {
volumeOffSets[key + 'volume'] = sessionStorage.getItem(key + 'volume');
});
return volumeOffSets;
}
export default (state, action) => {
if (!state) {
initialPadVolumes();
state = getVolumeOffSets();
}
switch (action.type) {
default:
return state;
}
};