From 5ea295f857952d80d2423be78618e5e3841fdec7 Mon Sep 17 00:00:00 2001 From: jackyzha0 Date: Fri, 22 May 2020 20:27:45 -0700 Subject: styling fixes --- frontend/src/components/NewPaste.js | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'frontend/src/components/NewPaste.js') 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() { -- cgit v1.2.3