mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Disabling download button when form is pending.
This commit is contained in:
parent
fded1e7492
commit
51bcc323af
1 changed files with 10 additions and 4 deletions
|
|
@ -10,14 +10,20 @@ class Downloader extends React.Component {
|
|||
this.state = {
|
||||
urls: '',
|
||||
valid: true,
|
||||
pending: false,
|
||||
};
|
||||
}
|
||||
|
||||
submitDownload = async () => {
|
||||
if (this.state.urls) {
|
||||
let response = await postDownload(this.state.urls);
|
||||
if (response.status === 204) {
|
||||
this.setState({urls: ''});
|
||||
this.setState({pending: true});
|
||||
try {
|
||||
let response = await postDownload(this.state.urls);
|
||||
if (response.status === 204) {
|
||||
this.setState({urls: '', pending: false});
|
||||
}
|
||||
} finally {
|
||||
this.setState({pending: false});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -42,7 +48,7 @@ class Downloader extends React.Component {
|
|||
|
||||
render() {
|
||||
let textareaPlaceholder = 'Enter one URL per line';
|
||||
let disabled = !this.state.urls || !this.state.valid;
|
||||
let disabled = !this.state.urls || !this.state.valid || this.state.pending;
|
||||
|
||||
return (
|
||||
<Form onSubmit={this.submitDownload}>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue