mirror of
https://github.com/VueTorrent/VueTorrent.git
synced 2025-03-14 03:59:53 +03:00
fix(AddTorrentDialog): Prevent undefined values from being sent through API (#1330)
This commit is contained in:
parent
3614081f19
commit
6575ade19e
4 changed files with 10 additions and 14 deletions
|
@ -137,19 +137,17 @@ const inactiveSeedingTimeLimit = computed({
|
|||
function submit() {
|
||||
if (!isFormValid.value) return
|
||||
|
||||
const promise = torrentStore.addTorrents(form.value, files.value)
|
||||
.then(() => {
|
||||
addTorrentStore.resetForm()
|
||||
close()
|
||||
})
|
||||
|
||||
toast.promise(promise, {
|
||||
toast.promise(torrentStore.addTorrents(files.value, urls.value, form.value), {
|
||||
pending: t('dialogs.add.pending'),
|
||||
error: t('dialogs.add.error', addTorrentStore.pendingTorrentsCount),
|
||||
success: t('dialogs.add.success', addTorrentStore.pendingTorrentsCount)
|
||||
}, {
|
||||
autoClose: 1500
|
||||
})
|
||||
.then(() => {
|
||||
addTorrentStore.resetForm()
|
||||
close()
|
||||
})
|
||||
}
|
||||
|
||||
function close() {
|
||||
|
|
|
@ -226,14 +226,14 @@ export class QBitApi {
|
|||
|
||||
// Post
|
||||
|
||||
async addTorrents(params: AddTorrentPayload, torrents: File[]): Promise<void> {
|
||||
async addTorrents(torrents: File[], urls: string, params: AddTorrentPayload): Promise<void> {
|
||||
let data
|
||||
if (torrents) {
|
||||
// torrent files
|
||||
const formData = new FormData()
|
||||
if (params) {
|
||||
for (const [key, value] of Object.entries(params)) {
|
||||
formData.append(key, value)
|
||||
!!value && formData.set(key, value)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -246,7 +246,7 @@ export class QBitApi {
|
|||
// magnet links
|
||||
data = new URLSearchParams(params as Parameters)
|
||||
}
|
||||
|
||||
!!urls && data.set('urls', urls)
|
||||
return this.axios.post('/torrents/add', data)
|
||||
}
|
||||
|
||||
|
|
|
@ -99,8 +99,8 @@ export const useTorrentStore = defineStore('torrents', () => {
|
|||
await qbit.setTorrentLocation(hashes, newPath)
|
||||
}
|
||||
|
||||
async function addTorrents(payload: AddTorrentPayload, torrents: File[]) {
|
||||
return await qbit.addTorrents(payload, torrents)
|
||||
async function addTorrents(torrents: File[], urls: string, payload: AddTorrentPayload) {
|
||||
return await qbit.addTorrents(torrents, urls, payload)
|
||||
}
|
||||
|
||||
async function getTorrentProperties(hash: string) {
|
||||
|
|
|
@ -49,8 +49,6 @@ export default interface AddTorrentPayload {
|
|||
tags?: string
|
||||
/** Set torrent upload speed limit. Unit in bytes/second */
|
||||
upLimit?: number
|
||||
/** URLs separated with newlines */
|
||||
urls?: string
|
||||
/** Whether to enable use of `downloadPath` */
|
||||
useDownloadPath?: boolean
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue