From 587ea68f55b31d9ff6d8259d26f14c4ec8acac33 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Mon, 9 Jan 2017 21:26:28 -0800 Subject: [PATCH] Replace more strings with constants --- js/components/Position.jsx | 15 +++++++++++---- js/components/Visualizer.jsx | 4 +++- js/components/Volume.jsx | 5 +++-- js/hotkeys.js | 12 +++++++++--- js/winamp.js | 4 +++- 5 files changed, 29 insertions(+), 11 deletions(-) diff --git a/js/components/Position.jsx b/js/components/Position.jsx index 00dfba5c..7ea77da1 100644 --- a/js/components/Position.jsx +++ b/js/components/Position.jsx @@ -1,6 +1,13 @@ import React from 'react'; import {connect} from 'react-redux'; +import { + SEEK_TO_PERCENT_COMPLETE, + SET_FOCUS, + UNSET_FOCUS, + SET_SCRUB_POSITION +} from '../actionTypes'; + const Position = ({position, seekToPercentComplete, displayedPosition, setPosition}) => { // In shade mode, the position slider shows up differently depending on if // it's near the start, middle or end of its progress @@ -41,12 +48,12 @@ const mapStateToProps = ({media, userInput}) => { const mapDispatchToProps = (dispatch) => ({ seekToPercentComplete: (e) => { - dispatch({type: 'SEEK_TO_PERCENT_COMPLETE', percent: e.target.value}); - dispatch({type: 'UNSET_FOCUS'}); + dispatch({type: SEEK_TO_PERCENT_COMPLETE, percent: e.target.value}); + dispatch({type: UNSET_FOCUS}); }, setPosition: (e) => { - dispatch({type: 'SET_FOCUS', input: 'position'}); - dispatch({type: 'SET_SCRUB_POSITION', position: e.target.value}); + dispatch({type: SET_FOCUS, input: 'position'}); + dispatch({type: SET_SCRUB_POSITION, position: e.target.value}); } }); diff --git a/js/components/Visualizer.jsx b/js/components/Visualizer.jsx index db72d971..dce1ade0 100644 --- a/js/components/Visualizer.jsx +++ b/js/components/Visualizer.jsx @@ -1,6 +1,8 @@ import React from 'react'; import {connect} from 'react-redux'; +import {TOGGLE_VISUALIZER_STYLE} from '../actionTypes'; + const OSCILLOSCOPE = 1; const BAR = 2; @@ -195,7 +197,7 @@ const mapStateToProps = (state) => ({ }); const mapDispatchToProps = (dispatch) => ({ - toggleVisualizer: () => dispatch({type: 'TOGGLE_VISUALIZER_STYLE'}) + toggleVisualizer: () => dispatch({type: TOGGLE_VISUALIZER_STYLE}) }); module.exports = connect(mapStateToProps, mapDispatchToProps)(Visualizer); diff --git a/js/components/Volume.jsx b/js/components/Volume.jsx index df99894c..b44152fa 100644 --- a/js/components/Volume.jsx +++ b/js/components/Volume.jsx @@ -2,6 +2,7 @@ import React from 'react'; import {connect} from 'react-redux'; import {setVolume} from '../actionCreators'; +import {SET_FOCUS, UNSET_FOCUS} from '../actionTypes'; const Volume = (props) => { const {volume} = props; @@ -30,8 +31,8 @@ const Volume = (props) => { const mapStateToProps = (state) => state.media; const mapDispatchToProps = (dispatch) => ({ - showMarquee: () => dispatch({type: 'SET_FOCUS', input: 'volume'}), - hideMarquee: () => dispatch({type: 'UNSET_FOCUS'}), + showMarquee: () => dispatch({type: SET_FOCUS, input: 'volume'}), + hideMarquee: () => dispatch({type: UNSET_FOCUS}), setVolume: (e) => dispatch(setVolume(e.target.value)) }); diff --git a/js/hotkeys.js b/js/hotkeys.js index 8057877f..edfb44c9 100644 --- a/js/hotkeys.js +++ b/js/hotkeys.js @@ -8,6 +8,12 @@ import { openFileDialog } from './actionCreators'; +import { + TOGGLE_DOUBLESIZE_MODE, + TOGGLE_TIME_MODE, + TOGGLE_LLAMA_MODE +} from './actionTypes'; + module.exports = function(winamp, {dispatch}) { let keylog = []; const trigger = [ @@ -24,12 +30,12 @@ module.exports = function(winamp, {dispatch}) { if (e.ctrlKey) { // Is CTRL depressed? switch (e.keyCode) { case 68: // CTRL+D - dispatch({type: 'TOGGLE_DOUBLESIZE_MODE'}); + dispatch({type: TOGGLE_DOUBLESIZE_MODE}); break; case 76: // CTRL+L FIXME break; case 84: // CTRL+T - dispatch({type: 'TOGGLE_TIME_MODE'}); + dispatch({type: TOGGLE_TIME_MODE}); break; } } else { @@ -107,7 +113,7 @@ module.exports = function(winamp, {dispatch}) { keylog.push(e.keyCode); keylog = keylog.slice(-10); if (keylog.toString() === trigger.toString()) { - dispatch({type: 'TOGGLE_LLAMA_MODE'}); + dispatch({type: TOGGLE_LLAMA_MODE}); } }); }; diff --git a/js/winamp.js b/js/winamp.js index 91a0e15d..751f86d2 100755 --- a/js/winamp.js +++ b/js/winamp.js @@ -9,6 +9,8 @@ import { setBalance } from './actionCreators'; +import {SET_MEDIA} from '../actionTypes'; + import '../css/winamp.css'; module.exports = { @@ -71,7 +73,7 @@ module.exports = { _loadBuffer: function(buffer) { function setMetaData() { this.dispatch({ - type: 'SET_MEDIA', + type: SET_MEDIA, kbps: '128', khz: Math.round(this.media.sampleRate() / 1000).toString(), channels: this.media.channels(),