Use promises

This commit is contained in:
DD committed 2018-02-23 16:25:28 -05:00
1 parent 868e401a40
commit 87ab4e2896
3 files changed
+13 -4

No files matched your search

+4 -3
View File
@@ -87,8 +87,9 @@ class CostumeTab extends React.Component {
this.props.vm.deleteCostume(costumeIndex);
}
handleDuplicateCostume (costumeIndex) {
this.props.vm.duplicateCostume(costumeIndex);
this.setState({selectedCostumeIndex: costumeIndex + 1});
this.props.vm.duplicateCostume(costumeIndex).then(() => {
this.setState({selectedCostumeIndex: costumeIndex + 1});
});
}
handleNewCostume () {
if (!this.props.vm.editingTarget) return;
@@ -203,7 +204,7 @@ CostumeTab.propTypes = {
costumes: PropTypes.arrayOf(PropTypes.shape({
url: PropTypes.string,
name: PropTypes.string.isRequired,
costumeId: PropTypes.number
skinId: PropTypes.number
}))
})
}),
+1 -1
View File
@@ -59,7 +59,7 @@ const mapStateToProps = (state, {selectedCostumeIndex}) => {
name: costume && costume.name,
rotationCenterX: costume && costume.rotationCenterX,
rotationCenterY: costume && costume.rotationCenterY,
svgId: editingTarget && `${editingTarget}${costume.costumeId}`
svgId: editingTarget && `${editingTarget}${costume.skinId}`
};
};
+8
View File
@@ -26,6 +26,7 @@ class SoundTab extends React.Component {
bindAll(this, [
'handleSelectSound',
'handleDeleteSound',
'handleDuplicateSound',
'handleNewSound'
]);
this.state = {selectedSoundIndex: 0};
@@ -56,6 +57,12 @@ class SoundTab extends React.Component {
}
}
handleDuplicateSound (soundIndex) {
this.props.vm.duplicateSound(soundIndex).then(() => {
this.setState({selectedSoundIndex: soundIndex + 1});
});
}
handleNewSound () {
if (!this.props.vm.editingTarget) {
return null;
@@ -116,6 +123,7 @@ class SoundTab extends React.Component {
}))}
selectedItemIndex={this.state.selectedSoundIndex}
onDeleteClick={this.handleDeleteSound}
onDuplicateClick={this.handleDuplicateSound}
onItemClick={this.handleSelectSound}
>
{sprite.sounds && sprite.sounds[this.state.selectedSoundIndex] ? (