diff --git a/src/components/Modals/AddModal.vue b/src/components/Modals/AddModal.vue index bde1cf8b..a973ce5a 100644 --- a/src/components/Modals/AddModal.vue +++ b/src/components/Modals/AddModal.vue @@ -282,8 +282,6 @@ export default { } }, created() { - this.$store.commit('FETCH_SETTINGS') - this.$store.commit('FETCH_CATEGORIES') this.urls = this.initialMagnet this.setSettings() if (this.openSuddenly == true) { @@ -294,11 +292,15 @@ export default { this.dTransition = 'scale-transition' }, methods: { - setSettings() { + async setSettings() { + await this.$store.dispatch('FETCH_SETTINGS') + await this.$store.commit('FETCH_CATEGORIES') const settings = this.getSettings() + console.log(settings) this.start = !settings.start_paused_enabled this.autoTMM = settings.auto_tmm_enabled this.root_folder = settings.create_subfolder_enabled + this.directory = settings.save_path }, addDropFile(e) { this.showWrapDrag = false diff --git a/src/components/Modals/SettingsModal/SettingsModal.vue b/src/components/Modals/SettingsModal/SettingsModal.vue index 69e5f90d..6d1f5aed 100644 --- a/src/components/Modals/SettingsModal/SettingsModal.vue +++ b/src/components/Modals/SettingsModal/SettingsModal.vue @@ -114,7 +114,7 @@ export default { } }, created() { - this.$store.commit('FETCH_SETTINGS') + this.$store.dispatch('FETCH_SETTINGS') }, methods: { close() { diff --git a/src/mixins/SettingsTab.js b/src/mixins/SettingsTab.js index f2bfbc8e..8cd8beb6 100644 --- a/src/mixins/SettingsTab.js +++ b/src/mixins/SettingsTab.js @@ -13,7 +13,7 @@ export default { qbit.setPreferences(this.getSettings()).then(() => { Vue.$toast.success(this.$t('toast.settingsSaved')) }) - await this.$store.commit('FETCH_SETTINGS') + await this.$store.dispatch('FETCH_SETTINGS') await this.$store.commit('SET_LANGUAGE') this.close() if (!this.settings.alternative_webui_enabled) { diff --git a/src/store/actions.js b/src/store/actions.js index d16d7915..d7a8ccfd 100644 --- a/src/store/actions.js +++ b/src/store/actions.js @@ -23,5 +23,11 @@ export default { Vue.$toast.error(i18n.t('toast.loginFailed')) return false + }, + FETCH_SETTINGS: async context => { + const { data } = await qbit.getAppPreferences() + context.commit('FETCH_SETTINGS', data) + + return data } } diff --git a/src/store/mutations.js b/src/store/mutations.js index 43906d26..2340ba64 100644 --- a/src/store/mutations.js +++ b/src/store/mutations.js @@ -65,9 +65,8 @@ export default { Torrents.update(data) DocumentTitle.update() }, - FETCH_SETTINGS: async state => { - const { data } = await qbit.getAppPreferences() - state.settings = data + FETCH_SETTINGS: async (state, settings) => { + state.settings = settings }, UPDATE_SORT_OPTIONS: (state, { hashes = [],