From 16cd15b44ee1d0d30faca2b7c19402e48b4542ba Mon Sep 17 00:00:00 2001 From: Kylart Date: Tue, 21 Nov 2017 18:46:49 +0100 Subject: [PATCH] Fix some bugs --- components/historyModal.vue | 1 + components/malForm.vue | 6 +----- store/modules/releases/actions.js | 35 +++++++++++++++++++------------ 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/components/historyModal.vue b/components/historyModal.vue index b2d6674..58cf1f4 100644 --- a/components/historyModal.vue +++ b/components/historyModal.vue @@ -96,6 +96,7 @@ }, refresh () { this.$store.dispatch('history/get') + this.generateHistory() }, close () { this.$store.commit('history/setModal', false) diff --git a/components/malForm.vue b/components/malForm.vue index 6100481..732ec56 100644 --- a/components/malForm.vue +++ b/components/malForm.vue @@ -229,6 +229,7 @@ methods: { close () { this.$store.commit('mal/showForm', false) + this.form = this.initForm }, submit () { const id = this.entry.id @@ -303,11 +304,6 @@ console.error((new Date()).toLocaleTimeString(), e) } } - }, - show (bool) { - if (!bool) { - this.form = this.initForm - } } } } diff --git a/store/modules/releases/actions.js b/store/modules/releases/actions.js index 2413069..1bcb910 100644 --- a/store/modules/releases/actions.js +++ b/store/modules/releases/actions.js @@ -76,28 +76,37 @@ export default { commit('empty') - const {data, status} = await axios.get('getLatestNyaa', { params: state.params }) - - if (status === 200) commit('set', data) - else if (status === 202) { - log(`An error occurred while getting the latest releases. Retrying in 45 seconds.`) - commit('setInfoSnackbar', 'Could not get the latest releases. Retrying in 45 seconds.', isRoot) - setTimeout(() => { - log(`Retrying to get latest releases.`) - dispatch('refresh').catch(err => { void (err) }) - }, 45 * 1000) - } else if (status === 204) { - const {data, status} = await axios.get(`getLatest.json?quality=${state.params.quality}`) + try { + const {data, status} = await axios.get('getLatestNyaa', { params: state.params }) if (status === 200) commit('set', data) - else if (status === 202 || status === 204) { + else if (status === 202) { log(`An error occurred while getting the latest releases. Retrying in 45 seconds.`) commit('setInfoSnackbar', 'Could not get the latest releases. Retrying in 45 seconds.', isRoot) setTimeout(() => { log(`Retrying to get latest releases.`) dispatch('refresh').catch(err => { void (err) }) }, 45 * 1000) + } else if (status === 204) { + const {data, status} = await axios.get(`getLatest.json?quality=${state.params.quality}`) + + if (status === 200) commit('set', data) + else if (status === 202 || status === 204) { + log(`An error occurred while getting the latest releases. Retrying in 45 seconds.`) + commit('setInfoSnackbar', 'Could not get the latest releases. Retrying in 45 seconds.', isRoot) + setTimeout(() => { + log(`Retrying to get latest releases.`) + dispatch('refresh').catch(err => { void (err) }) + }, 45 * 1000) + } } + } catch (e) { + log(`An error occurred while getting the latest releases. Retrying in 45 seconds.`, e) + commit('setInfoSnackbar', 'Could not get the latest releases. Retrying in 45 seconds.', isRoot) + setTimeout(() => { + log(`Retrying to get latest releases.`) + dispatch('refresh').catch(err => { void (err) }) + }, 45 * 1000) } }, async autoRefresh ({dispatch, commit, state}) {