feat: applied same cache technique of home to charts as well

This commit is contained in:
Roberto Tonino 2020-09-21 19:22:09 +02:00
parent 5593dc085e
commit b5d5a5761a
5 changed files with 25 additions and 18 deletions

File diff suppressed because one or more lines are too long

View File

@ -111,10 +111,11 @@ import { showView } from '@js/tabs.js'
import Downloads from '@/utils/downloads' import Downloads from '@/utils/downloads'
import Utils from '@/utils/utils' import Utils from '@/utils/utils'
import { getChartsData } from '@/data/charts'
import EventBus from '@/utils/EventBus' import EventBus from '@/utils/EventBus'
export default { export default {
name: 'the-charts-tab',
data() { data() {
return { return {
country: '', country: '',
@ -129,9 +130,12 @@ export default {
return this.getCharts.length === 0 return this.getCharts.length === 0
} }
}, },
async created() {
const chartsData = await getChartsData()
this.initCharts(chartsData)
},
mounted() { mounted() {
this.waitCharts()
// socket.on('init_charts', this.initCharts)
socket.on('setChartTracks', this.setTracklist) socket.on('setChartTracks', this.setTracklist)
}, },
methods: { methods: {
@ -190,8 +194,8 @@ export default {
this.country = '' this.country = ''
this.id = 0 this.id = 0
}, },
initCharts() { initCharts(chartsData) {
this.countries = this.getCharts this.countries = chartsData
this.country = localStorage.getItem('chart') || '' this.country = localStorage.getItem('chart') || ''
if (!this.country) return if (!this.country) return

View File

@ -39,7 +39,10 @@ const routes = [
{ {
path: '/charts', path: '/charts',
name: 'Charts', name: 'Charts',
component: TheChartsTab component: TheChartsTab,
meta: {
notKeepAlive: true
}
}, },
{ {
path: '/favorites', path: '/favorites',
@ -107,7 +110,7 @@ router.beforeEach((to, from, next) => {
// socket.emit('get_home_data') // socket.emit('get_home_data')
break break
case 'Charts': case 'Charts':
socket.emit('get_charts_data') // socket.emit('get_charts_data')
break break
default: default:

View File

@ -5,7 +5,7 @@ import Vue from 'vue'
import settings from '@/store/modules/settings' import settings from '@/store/modules/settings'
import defaultSettings from '@/store/modules/defaultSettings' import defaultSettings from '@/store/modules/defaultSettings'
import spotifyCredentials from '@/store/modules/spotifyCredentials' import spotifyCredentials from '@/store/modules/spotifyCredentials'
import charts from '@/store/modules/charts' // import charts from '@/store/modules/charts'
import favorites from '@/store/modules/favorites' import favorites from '@/store/modules/favorites'
import about from '@/store/modules/about' import about from '@/store/modules/about'
import login from '@/store/modules/login' import login from '@/store/modules/login'
@ -21,7 +21,7 @@ export default new Vuex.Store({
settings, settings,
defaultSettings, defaultSettings,
spotifyCredentials, spotifyCredentials,
charts, // charts,
favorites, favorites,
about, about,
login, login,

View File

@ -6,9 +6,9 @@ socket.on('connect', () => {
document.getElementById('start_app_placeholder').classList.add('loading_placeholder--hidden') document.getElementById('start_app_placeholder').classList.add('loading_placeholder--hidden')
}) })
socket.on('init_charts', charts => { // socket.on('init_charts', charts => {
store.dispatch('cacheCharts', charts) // store.dispatch('cacheCharts', charts)
}) // })
socket.on('init_favorites', favorites => { socket.on('init_favorites', favorites => {
favorites.tracks = JSON.stringify(favorites.tracks) favorites.tracks = JSON.stringify(favorites.tracks)