mirror of
https://github.com/VueTorrent/VueTorrent.git
synced 2025-02-26 04:10:52 +03:00
fix(AddTorrentDialog): Dialog was never initialized with default values (#1214)
This commit is contained in:
parent
f70bce4706
commit
44fd8d3861
3 changed files with 24 additions and 23 deletions
|
@ -7,6 +7,7 @@ import { useAuthStore } from '@/stores/auth'
|
|||
import { useDialogStore } from '@/stores/dialog'
|
||||
import { useLogStore } from '@/stores/logs'
|
||||
import { useMaindataStore } from '@/stores/maindata'
|
||||
import { useNavbarStore } from '@/stores/navbar.ts'
|
||||
import { usePreferenceStore } from '@/stores/preferences'
|
||||
import { useVueTorrentStore } from '@/stores/vuetorrent'
|
||||
|
||||
|
@ -21,6 +22,7 @@ const appStore = useAppStore()
|
|||
const dialogStore = useDialogStore()
|
||||
const logStore = useLogStore()
|
||||
const maindataStore = useMaindataStore()
|
||||
const navbarStore = useNavbarStore()
|
||||
const preferencesStore = usePreferenceStore()
|
||||
const vuetorrentStore = useVueTorrentStore()
|
||||
|
||||
|
@ -67,6 +69,7 @@ onBeforeMount(() => {
|
|||
vuetorrentStore.setLanguage(vuetorrentStore.language)
|
||||
checkAuthentication()
|
||||
blockContextMenu()
|
||||
navbarStore.initAddTorrentDialogForm()
|
||||
})
|
||||
|
||||
watch(
|
||||
|
@ -77,6 +80,8 @@ watch(
|
|||
await maindataStore.updateMaindata()
|
||||
await preferencesStore.fetchPreferences()
|
||||
await logStore.fetchLogs()
|
||||
await maindataStore.fetchCategories()
|
||||
await maindataStore.fetchTags()
|
||||
} else {
|
||||
appStore.clearIntervals()
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import { useNavbarStore } from '@/stores/navbar'
|
|||
import { usePreferenceStore } from '@/stores/preferences'
|
||||
import { useVueTorrentStore } from '@/stores/vuetorrent'
|
||||
import { AddTorrentPayload } from '@/types/qbit/payloads'
|
||||
import { computed, onBeforeMount, ref } from 'vue'
|
||||
import { computed, ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
|
@ -73,21 +73,6 @@ const close = () => {
|
|||
const onCategoryChanged = () => {
|
||||
navbarStore.addTorrentDialogForm.savepath = navbarStore.addTorrentDialogForm.category && navbarStore.addTorrentDialogForm.category.savePath ? navbarStore.addTorrentDialogForm.category.savePath : preferenceStore.preferences!.save_path
|
||||
}
|
||||
|
||||
onBeforeMount(async () => {
|
||||
const promises = []
|
||||
if (!preferenceStore.preferences) {
|
||||
promises.push(preferenceStore.fetchPreferences())
|
||||
}
|
||||
if (maindataStore.categories.length < 1) {
|
||||
promises.push(maindataStore.fetchCategories())
|
||||
}
|
||||
if (maindataStore.tags.length < 1) {
|
||||
promises.push(maindataStore.fetchTags())
|
||||
}
|
||||
|
||||
await Promise.all(promises)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
@ -12,6 +12,8 @@ export const useNavbarStore = defineStore(
|
|||
const downloadData = ref<number[]>(new Array(15).fill(0))
|
||||
const uploadData = ref<number[]>(new Array(15).fill(0))
|
||||
|
||||
const isAddTorrentDialogFirstInit = ref(true)
|
||||
|
||||
const addTorrentDialogFiles = ref<File[]>([])
|
||||
const addTorrentDialogUrls = ref('')
|
||||
|
||||
|
@ -51,25 +53,33 @@ export const useNavbarStore = defineStore(
|
|||
}
|
||||
}
|
||||
|
||||
function initAddTorrentDialogForm() {
|
||||
if (isAddTorrentDialogFirstInit.value) {
|
||||
isAddTorrentDialogFirstInit.value = false
|
||||
resetAddTorrentDialogForm()
|
||||
}
|
||||
}
|
||||
|
||||
function resetAddTorrentDialogForm() {
|
||||
addTorrentDialogUrls.value = ''
|
||||
addTorrentDialogFiles.value = []
|
||||
|
||||
addTorrentDialogForm.autoTMM = preferenceStore.preferences!.auto_tmm_enabled
|
||||
addTorrentDialogForm.skipChecking = false
|
||||
addTorrentDialogForm.sequentialDownload = false
|
||||
addTorrentDialogForm.firstLastPiecePrio = false
|
||||
addTorrentDialogForm.startNow = !preferenceStore.preferences!.start_paused_enabled
|
||||
addTorrentDialogForm.contentLayout = preferenceStore.preferences!.torrent_content_layout
|
||||
addTorrentDialogForm.stopCondition = preferenceStore.preferences!.torrent_stop_condition
|
||||
addTorrentDialogForm.savepath = preferenceStore.preferences!.save_path
|
||||
addTorrentDialogForm.category = null
|
||||
addTorrentDialogForm.contentLayout = preferenceStore.preferences!.torrent_content_layout
|
||||
addTorrentDialogForm.firstLastPiecePrio = false
|
||||
addTorrentDialogForm.savepath = preferenceStore.preferences!.save_path
|
||||
addTorrentDialogForm.sequentialDownload = false
|
||||
addTorrentDialogForm.skipChecking = false
|
||||
addTorrentDialogForm.startNow = !preferenceStore.preferences!.start_paused_enabled
|
||||
addTorrentDialogForm.stopCondition = preferenceStore.preferences!.torrent_stop_condition
|
||||
addTorrentDialogForm.tags = []
|
||||
}
|
||||
|
||||
return {
|
||||
downloadData,
|
||||
uploadData,
|
||||
isAddTorrentDialogFirstInit,
|
||||
addTorrentDialogFiles,
|
||||
addTorrentDialogUrls,
|
||||
addTorrentDialogForm,
|
||||
|
@ -77,6 +87,7 @@ export const useNavbarStore = defineStore(
|
|||
pushDownloadData,
|
||||
pushUploadData,
|
||||
pushTorrentToQueue,
|
||||
initAddTorrentDialogForm,
|
||||
resetAddTorrentDialogForm
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue