diff --git a/src/containers/costume-tab.jsx b/src/containers/costume-tab.jsx index 2e897c451031eae029dad95609c484f2ef645d72..c54f2667f855b022f419be5d72de874111a302f6 100644 --- a/src/containers/costume-tab.jsx +++ b/src/containers/costume-tab.jsx @@ -218,7 +218,6 @@ class CostumeTab extends React.Component { > {target.costumes ? <PaintEditorWrapper - {...props} selectedCostumeIndex={this.state.selectedCostumeIndex} /> : null diff --git a/src/containers/load-button.jsx b/src/containers/load-button.jsx index a7b78a638dcf87871ced71752a668beebe153f87..ad6ba9d4e9388d0f76377fd5c5e6dbd471ab93b1 100644 --- a/src/containers/load-button.jsx +++ b/src/containers/load-button.jsx @@ -16,7 +16,7 @@ class LoadButton extends React.Component { } handleChange (e) { const reader = new FileReader(); - reader.onload = () => this.props.loadProject(reader.result); + reader.onload = () => this.props.vm.fromJSON(reader.result); reader.readAsText(e.target.files[0]); } handleClick () { @@ -27,7 +27,7 @@ class LoadButton extends React.Component { } render () { const { - loadProject, // eslint-disable-line no-unused-vars + vm, // eslint-disable-line no-unused-vars ...props } = this.props; return ( @@ -42,11 +42,13 @@ class LoadButton extends React.Component { } LoadButton.propTypes = { - loadProject: PropTypes.func.isRequired + vm: PropTypes.shape({ + fromJSON: PropTypes.func + }) }; const mapStateToProps = state => ({ - loadProject: state.vm.fromJSON.bind(state.vm) + vm: state.vm }); export default connect( diff --git a/src/containers/paint-editor-wrapper.jsx b/src/containers/paint-editor-wrapper.jsx index 38cb3aa4a818b92ccc0ca2fa5a7946f0ade90a86..52bb5708f9c13e928be7fc6fd909fd0970c9b722 100644 --- a/src/containers/paint-editor-wrapper.jsx +++ b/src/containers/paint-editor-wrapper.jsx @@ -59,7 +59,8 @@ const mapStateToProps = (state, {selectedCostumeIndex}) => { name: costume && costume.name, rotationCenterX: costume && costume.rotationCenterX, rotationCenterY: costume && costume.rotationCenterY, - svgId: editingTarget && `${editingTarget}${costume.skinId}` + svgId: editingTarget && `${editingTarget}${costume.skinId}`, + vm: state.vm }; }; diff --git a/src/containers/save-button.jsx b/src/containers/save-button.jsx index f2ae497def0837fcf6eb0b888f3b84933d95039c..8e130fbf524012f8597006da58fb43bd58011438 100644 --- a/src/containers/save-button.jsx +++ b/src/containers/save-button.jsx @@ -15,7 +15,7 @@ class SaveButton extends React.Component { ]); } handleClick () { - const json = this.props.saveProjectSb3(); + const json = this.props.vm.saveProjectSb3(); // Download project data into a file - create link element, // simulate click on it, and then remove it. @@ -36,7 +36,7 @@ class SaveButton extends React.Component { } render () { const { - saveProjectSb3, // eslint-disable-line no-unused-vars + vm, // eslint-disable-line no-unused-vars ...props } = this.props; return ( @@ -57,11 +57,12 @@ class SaveButton extends React.Component { } SaveButton.propTypes = { - saveProjectSb3: PropTypes.func.isRequired -}; + vm: PropTypes.shape({ + saveProjectSb3: PropTypes.func + })}; const mapStateToProps = state => ({ - saveProjectSb3: state.vm.saveProjectSb3.bind(state.vm) + vm: state.vm }); export default connect( diff --git a/src/containers/sound-editor.jsx b/src/containers/sound-editor.jsx index bbe032c0b67bf897fb2ecdb6edf26cdc04b5c41f..de10ebc2cd066dc3729ea2afebeb1c116970389b 100644 --- a/src/containers/sound-editor.jsx +++ b/src/containers/sound-editor.jsx @@ -89,7 +89,7 @@ class SoundEditor extends React.Component { } this.resetState(samples, sampleRate); - this.props.onUpdateSoundBuffer( + this.props.vm.updateSoundBuffer( this.props.soundIndex, this.audioBufferPlayer.buffer, wavBuffer ? new Uint8Array(wavBuffer) : new Uint8Array()); @@ -112,7 +112,7 @@ class SoundEditor extends React.Component { this.setState({playhead}); } handleChangeName (name) { - this.props.onRenameSound(this.props.soundIndex, name); + this.props.vm.renameSound(this.props.soundIndex, name); } handleActivateTrim () { if (this.state.trimStart === null && this.state.trimEnd === null) { @@ -200,12 +200,14 @@ class SoundEditor extends React.Component { SoundEditor.propTypes = { name: PropTypes.string.isRequired, - onRenameSound: PropTypes.func.isRequired, - onUpdateSoundBuffer: PropTypes.func.isRequired, sampleRate: PropTypes.number, samples: PropTypes.instanceOf(Float32Array), soundId: PropTypes.string, - soundIndex: PropTypes.number + soundIndex: PropTypes.number, + vm: PropTypes.shape({ + updateSoundBuffer: PropTypes.func, + renameSound: PropTypes.func + }) }; const mapStateToProps = (state, {soundIndex}) => { @@ -219,8 +221,7 @@ const mapStateToProps = (state, {soundIndex}) => { sampleRate: audioBuffer.sampleRate, samples: audioBuffer.getChannelData(0), name: sound.name, - onRenameSound: state.vm.renameSound.bind(state.vm), - onUpdateSoundBuffer: state.vm.updateSoundBuffer.bind(state.vm) + vm: state.vm }; };