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

View File

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

View File

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

View File

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