diff --git a/web/src/components/Add/AddDialog.jsx b/web/src/components/Add/AddDialog.jsx
index 4c7225f..6d042fb 100644
--- a/web/src/components/Add/AddDialog.jsx
+++ b/web/src/components/Add/AddDialog.jsx
@@ -6,38 +6,19 @@ import DialogActions from '@material-ui/core/DialogActions'
import DialogContent from '@material-ui/core/DialogContent'
import DialogTitle from '@material-ui/core/DialogTitle'
import { torrentsHost } from 'utils/Hosts'
+import axios from 'axios'
export default function AddDialog({ handleClose }) {
- const [magnet, setMagnet] = useState('')
+ const [link, setLink] = useState('')
const [title, setTitle] = useState('')
const [poster, setPoster] = useState('')
- const inputMagnet = ({ target: { value } }) => setMagnet(value)
+ const inputMagnet = ({ target: { value } }) => setLink(value)
const inputTitle = ({ target: { value } }) => setTitle(value)
const inputPoster = ({ target: { value } }) => setPoster(value)
- const handleCloseSave = () => {
- try {
- if (!magnet) return
-
- fetch(torrentsHost(), {
- method: 'post',
- body: JSON.stringify({
- action: 'add',
- link: magnet,
- title,
- poster,
- save_to_db: true,
- }),
- headers: {
- Accept: 'application/json, text/plain, */*',
- 'Content-Type': 'application/json',
- },
- })
- handleClose()
- } catch (e) {
- console.log(e)
- }
+ const handleSave = () => {
+ axios.post(torrentsHost(), { action: 'add', link, title, poster, save_to_db: true }).finally(() => handleClose())
}
return (
@@ -63,7 +44,7 @@ export default function AddDialog({ handleClose }) {
Cancel
-
-
+
Save
diff --git a/web/src/components/Upload.jsx b/web/src/components/Upload.jsx
index 4eba3b4..8b1d7ab 100644
--- a/web/src/components/Upload.jsx
+++ b/web/src/components/Upload.jsx
@@ -9,6 +9,7 @@ export default function UploadDialog() {
const handleCapture = ({ target: { files } }) => {
const [file] = files
const data = new FormData()
+ data.append('save', 'true')
data.append('file', file)
axios.post(torrentUploadHost(), data)
}
diff --git a/web/src/utils/Utils.js b/web/src/utils/Utils.js
index a26095b..cee820b 100644
--- a/web/src/utils/Utils.js
+++ b/web/src/utils/Utils.js
@@ -10,4 +10,4 @@ export function getPeerString(torrent) {
}
export const shortenText = (text, sympolAmount) =>
- text.slice(0, sympolAmount) + (text.length > sympolAmount ? '...' : '')
+ text ? text.slice(0, sympolAmount) + (text.length > sympolAmount ? '...' : '') : ''