AddDialog devided on two parts for correct unmounting after dialog is closed

This commit is contained in:
Daniel Shleifman
2021-05-24 10:11:35 +03:00
parent 71cf096a4a
commit fcf4faff4a
9 changed files with 22910 additions and 139 deletions

View File

@@ -5,30 +5,31 @@ import ListItemText from '@material-ui/core/ListItemText'
import DeleteIcon from '@material-ui/icons/Delete'
import { torrentsHost } from '../utils/Hosts'
export default function RemoveAll() {
const fnRemoveAll = () => {
fetch(torrentsHost(), {
method: 'post',
body: JSON.stringify({ action: 'list' }),
headers: {
Accept: 'application/json, text/plain, */*',
'Content-Type': 'application/json',
},
})
.then((res) => res.json())
.then((json) => {
json.forEach((torr) => {
fetch(torrentsHost(), {
method: 'post',
body: JSON.stringify({ action: 'rem', hash: torr.hash }),
headers: {
Accept: 'application/json, text/plain, */*',
'Content-Type': 'application/json',
},
})
const fnRemoveAll = () => {
fetch(torrentsHost(), {
method: 'post',
body: JSON.stringify({ action: 'list' }),
headers: {
Accept: 'application/json, text/plain, */*',
'Content-Type': 'application/json',
},
})
.then((res) => res.json())
.then((json) => {
json.forEach((torr) => {
fetch(torrentsHost(), {
method: 'post',
body: JSON.stringify({ action: 'rem', hash: torr.hash }),
headers: {
Accept: 'application/json, text/plain, */*',
'Content-Type': 'application/json',
},
})
})
}
})
}
export default function RemoveAll() {
return (
<ListItem button key="Remove all" onClick={fnRemoveAll}>
<ListItemIcon>