webamp/js/reducers/display.js
2018-05-13 12:36:15 -07:00

64 lines
1.7 KiB
JavaScript

import {
CLOSE_WINAMP,
SET_SKIN_DATA,
START_WORKING,
STEP_MARQUEE,
STOP_WORKING,
TOGGLE_DOUBLESIZE_MODE,
TOGGLE_LLAMA_MODE,
TOGGLE_VISUALIZER_STYLE,
SET_PLAYLIST_SCROLL_POSITION
} from "../actionTypes";
const defaultDisplayState = {
doubled: false,
marqueeStep: 0,
loading: true,
llama: false,
closed: false,
working: false,
skinImages: {},
skinColors: null,
skinCursors: null,
skinPlaylistStyle: {},
skinRegion: {},
visualizerStyle: 2,
playlistScrollPosition: 0
};
const display = (state = defaultDisplayState, action) => {
switch (action.type) {
case TOGGLE_DOUBLESIZE_MODE:
return { ...state, doubled: !state.doubled };
case TOGGLE_LLAMA_MODE:
return { ...state, llama: !state.llama };
case STEP_MARQUEE:
// TODO: Prevent this from becoming huge
return { ...state, marqueeStep: state.marqueeStep + 1 };
case STOP_WORKING:
return { ...state, working: false };
case START_WORKING:
return { ...state, working: true };
case CLOSE_WINAMP:
return { ...state, closed: true };
case SET_SKIN_DATA:
return {
...state,
loading: false,
skinImages: action.skinImages,
skinColors: action.skinColors,
skinPlaylistStyle: action.skinPlaylistStyle,
skinCursors: action.skinCursors,
skinRegion: action.skinRegion,
skinGenLetterWidths: action.skinGenLetterWidths
};
case TOGGLE_VISUALIZER_STYLE:
return { ...state, visualizerStyle: (state.visualizerStyle + 1) % 3 };
case SET_PLAYLIST_SCROLL_POSITION:
return { ...state, playlistScrollPosition: action.position };
default:
return state;
}
};
export default display;