diff --git a/components/metadata/editor.jsx b/components/metadata/editor.jsx index 302ab2b..ec7b225 100644 --- a/components/metadata/editor.jsx +++ b/components/metadata/editor.jsx @@ -4,9 +4,11 @@ import Button from '../button' import Radium from 'radium' import TrackNumbers from './track-numbers.jsx' import { store } from '../../client.js' +import shallowCompare from 'react-addons-shallow-compare' const {remote} = require('electron') const userData = remote.app.getPath('userData') const ffmpeg = require('fluent-ffmpeg') + const fs = require('fs') @Radium @@ -43,19 +45,23 @@ export default class Editor extends Component { source.on('end', () => { fs.unlinkSync(temp) store.dispatch({type: 'UPDATE_METADATA', track: this.props.selected, albums: this.props.library.albums, tracks: this.props.library.tracks}) + this.props.reset() }) }) } + shouldComponentUpdate = (nextProps, nextState) => { + return shallowCompare(this, nextProps, nextState) + } render () { return (
- - - - - - + + + + + +
diff --git a/components/metadata/index.jsx b/components/metadata/index.jsx index 0052f31..1d3e850 100644 --- a/components/metadata/index.jsx +++ b/components/metadata/index.jsx @@ -10,7 +10,7 @@ const fs = require('fs') @Radium export default class Metadata extends Component { constructor (props) { - super () + super() this.state = { selected: false, index: false @@ -22,6 +22,9 @@ export default class Metadata extends Component { select (index) { this.setState({selected: this.props.library.tracks[index], index: index}) } + reset = () => { + this.setState({selected: false, index: false}) + } handleChange = event => { let selected = {...this.state.selected, [event.target.dataset.label]: event.target.value} this.setState({selected}) @@ -98,7 +101,7 @@ export default class Metadata extends Component { ))} - + ) }