import { ChangeVolume, ToggleAudioEnabled } from '../actions/audio';
import { AudioSettings } from '../types';
import { CHANGE_VOLUME, TOGGLE_AUDIO_ENABLED } from '../constants';

const initial: AudioSettings = {
  enabled: true,
  volume: 0.1
};

type AudioAction = ChangeVolume | ToggleAudioEnabled;

export default (state = initial, action: AudioAction): AudioSettings => {
  switch (action.type) {
    case CHANGE_VOLUME:
      return {
        ...state,
        volume: action.value
      };
    case TOGGLE_AUDIO_ENABLED:
      return {
        ...state,
        enabled: state.enabled
      };
    default:
      return state;
  }
};

import { ChangeVolume, ToggleAudioEnabled } from '../actions/audio';
import { AudioSettings } from '../types';
import { CHANGE_VOLUME, TOGGLE_AUDIO_ENABLED } from '../constants';

const initial: AudioSettings = {
  enabled: true,
  volume: 0.1
};

type AudioAction = ChangeVolume | ToggleAudioEnabled;

export default (state = initial, action: AudioAction): AudioSettings => {
  switch (action.type) {
    case CHANGE_VOLUME:
      return {
        ...state,
        volume: action.value
      };
    case TOGGLE_AUDIO_ENABLED:
      return {
        ...state,
        enabled: !state.enabled
      };
    default:
      return state;
  }
};

Fix bug causing audio to not toggle.
Fix bug causing audio to not toggle.
