Creating ClearFailedDownloads button.

This commit is contained in:
Roland 2022-04-01 16:45:59 -06:00
parent c4f511e469
commit 7ac3fbea2b
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
5 changed files with 92 additions and 7 deletions

View file

@ -11,7 +11,15 @@ import {
Placeholder,
Table
} from "semantic-ui-react";
import {clearDownloads, getDownloads, getSettings, killDownload, postDownload, saveSettings} from "../api";
import {
clearCompletedDownloads,
clearFailedDownloads,
getDownloads,
getSettings,
killDownload,
postDownload,
saveSettings
} from "../api";
import TimezoneSelect from 'react-timezone-select';
import {
DisableDownloadsToggle,
@ -203,8 +211,11 @@ function ClearCompleteDownloads() {
async function localClearDownloads() {
setDisabled(true);
await clearDownloads();
setDisabled(false);
try {
await clearCompletedDownloads();
} finally {
setDisabled(false);
}
}
return <>
@ -216,6 +227,36 @@ function ClearCompleteDownloads() {
</>
}
function ClearFailedDownloads() {
const [open, setOpen] = React.useState(false);
const [disabled, setDisabled] = React.useState(false);
async function localDeleteFailed() {
setDisabled(true);
try {
await clearFailedDownloads();
} finally {
setDisabled(false);
setOpen(false);
}
}
return <>
<Button
onClick={() => setOpen(true)}
disabled={disabled}
color='red'
>Clear Failed</Button>
<Confirm
open={open}
content='Are you sure you want to delete failed downloads? They will not be retried.'
confirmButton='Delete'
onCancel={() => setOpen(false)}
onConfirm={localDeleteFailed}
/>
</>
}
class DownloadRow extends React.Component {
render() {
@ -408,6 +449,7 @@ class Downloads extends React.Component {
onceTable = (
<>
<ClearCompleteDownloads/>
<ClearFailedDownloads/>
<Table>
{stoppableHeader}
<Table.Body>