aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/components/NewPaste.js
diff options
context:
space:
mode:
authorjackyzha0 <[email protected]>2020-05-22 20:27:45 -0700
committerjackyzha0 <[email protected]>2020-05-22 20:27:45 -0700
commit5ea295f857952d80d2423be78618e5e3841fdec7 (patch)
treef50aaebd9d3af23a067e5085f8f3aa2272441ecd /frontend/src/components/NewPaste.js
parentMerge pull request #29 from jackyzha0/order-langs (diff)
downloadctrl-v-5ea295f857952d80d2423be78618e5e3841fdec7.tar.xz
ctrl-v-5ea295f857952d80d2423be78618e5e3841fdec7.zip
styling fixes
Diffstat (limited to 'frontend/src/components/NewPaste.js')
-rw-r--r--frontend/src/components/NewPaste.js34
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() {