diff options
Diffstat (limited to 'frontend/src/components/NewPaste.js')
| -rw-r--r-- | frontend/src/components/NewPaste.js | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/frontend/src/components/NewPaste.js b/frontend/src/components/NewPaste.js index 6e1b507..e13e7df 100644 --- a/frontend/src/components/NewPaste.js +++ b/frontend/src/components/NewPaste.js @@ -43,22 +43,26 @@ class NewPaste extends React.Component { handleSubmit(event) { event.preventDefault(); - PostNewPaste(this.state) - .then((response) => { - // on success, redir - this.setState({ hash: response.data.hash }) - }).catch((error) => { - const resp = error.response - // some weird err - if (resp !== undefined) { - const errTxt = `${resp.statusText}: ${resp.data}` - this.ErrorLabel.current.showMessage(errTxt) - } else { - // some weird err (e.g. network) - this.ErrorLabel.current.showMessage(error) - } - }); + // prevent resubmission + if (!this.state.hash) { + PostNewPaste(this.state) + .then((response) => { + // on success, redir + this.setState({ hash: response.data.hash }) + }).catch((error) => { + const resp = error.response + + // some weird err + if (resp !== undefined) { + const errTxt = `${resp.statusText}: ${resp.data}` + this.ErrorLabel.current.showMessage(errTxt) + } else { + // some weird err (e.g. network) + this.ErrorLabel.current.showMessage(error) + } + }); + } } render() { |