From 5738629c798d2a18c5452b579afe137bc2b7a0ed Mon Sep 17 00:00:00 2001 From: Kylart Date: Sat, 29 Apr 2017 21:07:04 +0200 Subject: [PATCH] Fixed retry for releases page if any error occurs. --- package.json | 2 +- store/index.js | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index e7f5da8..3537d53 100755 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "colors": "^1.1.2", "cross-env": "^3.1.4", "devtron": "^1.4.0", - "electron": "^1.6.2", + "electron": "^1.6.6", "electron-builder": "^17.1.1", "stylus": "^0.54.5", "stylus-loader": "^3.0.1", diff --git a/store/index.js b/store/index.js index 330775c..1c3e9ba 100644 --- a/store/index.js +++ b/store/index.js @@ -76,6 +76,10 @@ const store = new Vuex.Store({ state.config = config }, + setErrorSnackbar(state, data) { + state.errorSnackbar.text = data + state.errorSnackbar.show = true + }, setCurrentSeason(state, data) { state.year = data.year state.season = data.season @@ -147,17 +151,18 @@ const store = new Vuex.Store({ } }, actions: { - async releasesInit({state, commit, dispatch}) { + async releasesInit({state, commit}) { console.log('[INIT] Releases') const {data, status} = await axios.get(`releases.json?fansub=${state.releaseFansub}&quality=${state.releaseQuality}`) if (status === 200) commit('setReleases', data) else { - state.errorSnackBar.text = 'An error occurred while getting the latest releases. Retrying in 30 seconds.' - setTimeout(() => { + console.log(`[${(new Date()).toLocaleTimeString()}]: An error occurred while getting the latest releases. Retrying in 30 seconds.`) + commit('setErrorSnackbar', 'Could not get the latest releases. Retrying in 30 seconds.') + setTimeout(function () { console.log(`[${(new Date()).toLocaleTimeString()}]: Retrying to get latest releases.`) - dispatch('releasesInit') + store.dispatch('releasesInit') }, 30 * 1000) } }