Prevent rendering sound editor for non-existant sounds

This commit is contained in:
Paul Kaplan committed 2017-07-24 08:51:26 -04:00
1 parent c9565f01ca
commit a3ad670108
1 file changed
+2 -2
+2 -2
View File
@@ -38,7 +38,7 @@ class SoundTab extends React.Component {
const target = editingTarget && sprites[editingTarget] ? sprites[editingTarget] : stage;
if (target && target.sounds && this.state.selectedSoundIndex > target.sounds.length - 1) {
this.setState({selectedSoundIndex: target.sounds.length - 1});
this.setState({selectedSoundIndex: Math.max(target.sounds.length - 1, 0)});
}
}
@@ -106,7 +106,7 @@ class SoundTab extends React.Component {
onDeleteClick={this.handleDeleteSound}
onItemClick={this.handleSelectSound}
>
{target.sounds ? (
{target.sounds && target.sounds.length > 0 ? (
<SoundEditor soundIndex={this.state.selectedSoundIndex} />
) : null}
{this.props.soundRecorderVisible ? (