mirror of
https://github.com/TrentSPalmer/fcc-challenges.git
synced 2024-10-31 21:38:46 -07:00
25 lines
614 B
JavaScript
25 lines
614 B
JavaScript
|
import { padsArray } from "../Globals";
|
||
|
import { TOGGLEMETRONOME } from "../actions/toggleMetronomeIsPlayingAction.js";
|
||
|
|
||
|
const initMetronomeIsPlaying = () => {
|
||
|
const metronomePlayingStates = {};
|
||
|
padsArray.forEach(key => {
|
||
|
metronomePlayingStates[key + 'metronomeIsPlaying'] = false;
|
||
|
});
|
||
|
return metronomePlayingStates;
|
||
|
};
|
||
|
|
||
|
export default (state, action) => {
|
||
|
if (!state) {
|
||
|
state = initMetronomeIsPlaying();
|
||
|
}
|
||
|
|
||
|
switch (action.type) {
|
||
|
case TOGGLEMETRONOME:
|
||
|
state[action.key + 'metronomeIsPlaying'] = action.metronomeIsPlaying;
|
||
|
return state;
|
||
|
default:
|
||
|
return state;
|
||
|
}
|
||
|
}
|