diff --git a/js/actionCreators.js b/js/actionCreators.js
index e4fa8c12..a5d448ab 100644
--- a/js/actionCreators.js
+++ b/js/actionCreators.js
@@ -108,3 +108,7 @@ export function setSkinFromFilename(filename) {
const url = `https://cdn.rawgit.com/captbaritone/winamp-skins/master/v2/${filename}`;
return setSkinFromUrl(url);
}
+
+export function openFileDialog(winamp) {
+ winamp.openFileDialog();
+}
diff --git a/js/components/ContextMenu.jsx b/js/components/ContextMenu.jsx
index ef328de6..118c1368 100644
--- a/js/components/ContextMenu.jsx
+++ b/js/components/ContextMenu.jsx
@@ -1,7 +1,7 @@
import React from 'react';
import {connect} from 'react-redux';
-import {close, setSkinFromFilename} from '../actionCreators';
+import {close, setSkinFromFilename, openFileDialog} from '../actionCreators';
import '../../css/context-menu.css';
@@ -25,7 +25,7 @@ class ContextMenu extends React.Component {
}
openFileDialog() {
- this.props.dispatch({type: 'OPEN_FILE_DIALOG'});
+ openFileDialog(this.props.winamp);
}
close() {
diff --git a/js/components/Eject.jsx b/js/components/Eject.jsx
index 4a753b4e..624e6883 100644
--- a/js/components/Eject.jsx
+++ b/js/components/Eject.jsx
@@ -1,6 +1,8 @@
import React from 'react';
import {connect} from 'react-redux';
+import {openFileDialog} from '../actionCreators';
+
class Eject extends React.Component {
constructor(props) {
@@ -8,7 +10,7 @@ class Eject extends React.Component {
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
- this.props.dispatch({type: 'OPEN_FILE_DIALOG'});
+ openFileDialog(this.props.winamp);
}
render() {
return
{
-
+
diff --git a/js/hotkeys.js b/js/hotkeys.js
index d59702ac..7a686de9 100644
--- a/js/hotkeys.js
+++ b/js/hotkeys.js
@@ -4,7 +4,8 @@ import {
stop,
adjustVolume,
toggleRepeat,
- toggleShuffle
+ toggleShuffle,
+ openFileDialog
} from './actionCreators';
module.exports = function(winamp, store) {
@@ -36,7 +37,7 @@ module.exports = function(winamp, store) {
// C
case 67: store.dispatch(pause(winamp.media)); break;
// L
- case 76: store.dispatch({type: 'OPEN_FILE_DIALOG'}); break;
+ case 76: openFileDialog(winamp); break;
// R
case 82: store.dispatch(toggleRepeat(winamp.media)); break;
// S
@@ -47,7 +48,7 @@ module.exports = function(winamp, store) {
case 88: store.dispatch(play(winamp.media)); break;
case 90: winamp.previous(); break; // Z
// numpad 0
- case 96: store.dispatch({type: 'OPEN_FILE_DIALOG'}); break;
+ case 96: openFileDialog(winamp); break;
case 97: winamp.previous(10); break; // numpad 1
// numpad 2
case 98: store.dispatch(adjustVolume(winamp.media, -1)); break;
diff --git a/js/index.js b/js/index.js
index 232ff06d..d384e41c 100644
--- a/js/index.js
+++ b/js/index.js
@@ -4,7 +4,7 @@ import {Provider} from 'react-redux';
import {createStore, applyMiddleware} from 'redux';
import thunk from 'redux-thunk';
-import createReducer from './reducers';
+import reducer from './reducers';
import Browser from './browser';
import MainWindow from './components/MainWindow.jsx';
@@ -15,7 +15,7 @@ import Skin from './components/Skin.jsx';
if (new Browser(window).isCompatible) {
const winamp = Winamp;
const store = createStore(
- createReducer(winamp),
+ reducer,
window.devToolsExtension && window.devToolsExtension(),
applyMiddleware(thunk)
);
diff --git a/js/reducers.js b/js/reducers.js
index 31a23d1f..721fa392 100644
--- a/js/reducers.js
+++ b/js/reducers.js
@@ -131,27 +131,11 @@ const media = (state, action) => {
}
};
-const createReducer = (winamp) => {
+const reducer = combineReducers({
+ userInput,
+ display,
+ contextMenu,
+ media
+});
- const reducer = combineReducers({
- userInput,
- display,
- contextMenu,
- media
- });
-
- // Add in the temporary actions that don't modify the state.
- return (state, action) => {
- state = reducer(state, action);
- switch (action.type) {
- case 'OPEN_FILE_DIALOG':
- // TODO: Figure out how to make this pure
- winamp.openFileDialog();
- return state;
- default:
- return state;
- }
- };
-};
-
-export default createReducer;
+export default reducer;