mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-23 01:57:29 +00:00
Move openFileDialog to actionCreators
This commit is contained in:
parent
dc81083ed3
commit
d321a16170
7 changed files with 23 additions and 32 deletions
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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 <div
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ const MainWindow = (props) => {
|
|||
</div>
|
||||
<Position mediaPlayer={props.mediaPlayer} />
|
||||
<ActionButtons mediaPlayer={props.mediaPlayer} />
|
||||
<Eject />
|
||||
<Eject winamp={props.winamp} />
|
||||
<div className='shuffle-repeat'>
|
||||
<Shuffle mediaPlayer={props.mediaPlayer} />
|
||||
<Repeat mediaPlayer={props.mediaPlayer} />
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue