From 75dbed61fa3aa8c3ca9bf22d43ad1c1a9f21b0a6 Mon Sep 17 00:00:00 2001 From: Eric Rosenbaum <eric.rosenbaum@gmail.com> Date: Tue, 23 Jul 2019 17:51:46 -0400 Subject: [PATCH] Fix bug where play after paste used old selection state --- src/containers/sound-editor.jsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/containers/sound-editor.jsx b/src/containers/sound-editor.jsx index 2de6077ca..930ad07df 100644 --- a/src/containers/sound-editor.jsx +++ b/src/containers/sound-editor.jsx @@ -334,6 +334,7 @@ class SoundEditor extends React.Component { newSamples.set(this.props.samples, 0); newSamples.set(this.state.copyBuffer.samples, this.props.samples.length); this.submitNewSamples(newSamples, this.props.sampleRate, false); + this.handlePlay(); } else { // else replace the selection with the pasted sound const trimStartSamples = this.state.trimStart * this.props.samples.length; @@ -352,15 +353,12 @@ class SoundEditor extends React.Component { const newDurationSeconds = newSamples.length / this.state.copyBuffer.sampleRate; const adjustedTrimStart = trimStartSeconds / newDurationSeconds; const adjustedTrimEnd = trimEndSeconds / newDurationSeconds; + this.submitNewSamples(newSamples, this.props.sampleRate, false); this.setState({ trimStart: adjustedTrimStart, trimEnd: adjustedTrimEnd - }); - - this.submitNewSamples(newSamples, this.props.sampleRate, false); + }, this.handlePlay); } - - this.handlePlay(); } handlePaste () { if (!this.state.copyBuffer) return; -- GitLab