Returning download response.

This commit is contained in:
Roland 2023-07-21 21:23:15 -06:00
parent 59c4ab2502
commit 863f26b519
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
3 changed files with 5 additions and 10 deletions

View file

@ -37,6 +37,7 @@ async function apiCall(url, method, body, ms = 60_000) {
// Request encountered an error.
let copy = response.clone();
const content = await copy.json();
console.debug('API error response json', content);
const code = content['code'];
if (response.status === 403 && code === 'WROL_MODE_ENABLED') {
toast({
@ -463,11 +464,7 @@ export async function postDownload(urls, downloader, frequency, sub_downloader,
body['tag_names'] = tagNames;
}
let response = await apiPost(`${API_URI}/download`, body);
if (response.status !== 204) {
const content = await response.json();
console.error(content);
throw Error(content['error']);
}
return response;
}
export async function killDownload(download_id) {

View file

@ -1295,7 +1295,7 @@ export function useAPIButton(
// Create button with or without theme. Pass all props to the <Button/> (except props.children).
const buttonArgs = {color, onClick: localOnClick, disabled, loading: pending, size, floated, ...props};
let buttonContent = <>{props.children}</>;
let buttonContent = props.children || null;
if (icon) {
// Send Icon as Button properties.
buttonContent = null;

View file

@ -179,8 +179,7 @@ class ChannelDownload extends React.Component {
this.setState({frequency: value, success: false});
}
handleSubmit = async (e) => {
e.preventDefault();
handleSubmit = async () => {
this.setState({disabled: true, pending: true, success: null, error: null});
const {url, frequency} = this.state;
if (!url) {
@ -289,8 +288,7 @@ class RSSDownload extends ChannelDownload {
this.setState({[name]: value});
}
handleSubmit = async (e) => {
e.preventDefault();
handleSubmit = async () => {
this.setState({disabled: true, pending: true, success: null, error: null});
const {url, frequency, sub_downloader, excludedURLs} = this.state;
if (!url) {