From 829a52ff78706d02d7f9ac5861bf5712d06f339f Mon Sep 17 00:00:00 2001 From: Kylart Date: Fri, 2 Jun 2017 19:31:07 +0200 Subject: [PATCH] Improved handling of "site-down" errors at init Now uninstall devtron on production Removed unnecessary comments in store/index.js Now working on adapting to Vuetifyjs 0.12 --- README.md | 2 +- main.js | 6 ++++-- pages/seasons.vue | 29 +++++++++++++++++++++++++++++ store/index.js | 12 +++++++++--- test/nightwatch/main.test.js | 12 +++++++++--- 5 files changed, 52 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index a1c00c1..4a70b57 100755 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ This software allows one to: list of torrent magnets to paste in a torrent client on a distant server. * Get information from any anime (those come from myanimelist.net) __COMMING SOON__. * Get anime-related news from MyAnimeList.net. -* Get seasonal releases information (from [www.livechart.me](www.livechart.me)). +* Get seasonal releases information (from [www.livechart.me](https://www.livechart.me)). * Manage your anime files (watch and delete on click) * Manage watch lists. * More features are to come. diff --git a/main.js b/main.js index 3f44247..1f51e21 100755 --- a/main.js +++ b/main.js @@ -33,7 +33,7 @@ if (config.dev) { } // Listen the server -server.listen(12345) +server.listen() const _NUXT_URL_ = `http://localhost:${server.address().port}` console.log(`KawAnime is at ${_NUXT_URL_}`) @@ -63,7 +63,7 @@ dialog.showErrorBox = (title, content) => { console.log(`${title}\n${content}`) } -process.on('uncaughtException', function (err) { +process.on('uncaughtException', (err) => { console.error('Uncaught exception occurred in main process.\n' + err) }) @@ -121,6 +121,8 @@ app.on('ready', () => { // Dev tools if (config.dev) { require('devtron').install() + } else { + require('devtron').uninstall() } newWin() diff --git a/pages/seasons.vue b/pages/seasons.vue index 86644d5..18502d5 100644 --- a/pages/seasons.vue +++ b/pages/seasons.vue @@ -119,6 +119,13 @@ Add to «Seen» + + + + Add to + + + @@ -149,6 +156,21 @@ + + + + Add {{ choiceTitle }} to + + + + To do + + + + Add + + + @@ -159,6 +181,9 @@ export default { data () { return { + choiceDialog: false, + choiceTitle: '', + choices: [], modalTitle: '', modalText: '', modal: false, @@ -258,6 +283,10 @@ listName: listName, entry: entry }) + }, + showChoices (name) { + this.choiceTitle = name + this.choiceDialog = true } } } diff --git a/store/index.js b/store/index.js index cea8ed8..33c074c 100644 --- a/store/index.js +++ b/store/index.js @@ -113,8 +113,6 @@ const store = new Vuex.Store({ }, setReleases: function (state, data) { state.releases = data - - // Update time whenever KawAnime receives new releases. state.releasesUpdateTime = (new Date()).toLocaleTimeString() log(`Releases updated.`) @@ -231,6 +229,8 @@ const store = new Vuex.Store({ dispatch('releasesInit').catch(err => { void (err) }) }, 45 * 1000) } else if (status === 204) { + log('nyaa.si does not respond... Switching to nyaa.pantsu.cat.') + commit('setReleaseParams', { fansub: state.config.fansub, quality: state.config.quality, @@ -251,6 +251,8 @@ const store = new Vuex.Store({ dispatch('releasesInit').catch(err => { void (err) }) }, 45 * 1000) } else if (status === 204) { + log('nyaa.pantsu.cat does not respond... Switching to HorribleSubs.') + commit('setReleaseParams', { fansub: state.config.fansub, quality: state.config.quality, @@ -263,13 +265,17 @@ const store = new Vuex.Store({ commit('setReleases', data) if (state.autoRefreshReleases === true) dispatch('autoRefreshReleases') - } 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.') setTimeout(function () { log(`Retrying to get latest releases.`) dispatch('releasesInit').catch(err => { void (err) }) }, 45 * 1000) + } else if (status === 204) { + log('HorribleSubs does not respond. Retrying with nyaa.si.') + + dispatch('releasesInit') } } } diff --git a/test/nightwatch/main.test.js b/test/nightwatch/main.test.js index 028a975..9b101ce 100644 --- a/test/nightwatch/main.test.js +++ b/test/nightwatch/main.test.js @@ -47,8 +47,8 @@ module.exports = { // adapted from: https://git.io/vodU0 done() }) }, - 'Getting downloader page': function (browser) { - browser + 'Getting downloader page and downloading some anime': function (client) { + client .url(`${uri}/downloader`) .waitForElementVisible('body') .assert.title('KawAnime') @@ -68,7 +68,13 @@ module.exports = { // adapted from: https://git.io/vodU0 .assert.visible('#download-btn') .click('#download-btn') .waitForElementVisible('div.modal-text') - .pause(3000) + .end() + }, + 'Getting season page': function (client) { + client + .url(`${uri}/seasons`) + .waitForElementVisible('body') + .assert.title('KawAnime') .end() }, after: function () {