Replace more strings with constants

This commit is contained in:
Jordan Eldredge 2017-01-09 21:26:28 -08:00
parent d0faa63cf8
commit 587ea68f55
5 changed files with 29 additions and 11 deletions

View file

@ -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});
}
});

View file

@ -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);

View file

@ -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))
});

View file

@ -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});
}
});
};

View file

@ -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(),