Fixed retry for releases page if any error occurs.

This commit is contained in:
Kylart 2017-04-29 21:07:04 +02:00
parent 3599c597a5
commit 5738629c79
2 changed files with 10 additions and 5 deletions

View File

@ -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",

View File

@ -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)
}
}