feat: removed unused code
This commit is contained in:
		
							parent
							
								
									b5d5a5761a
								
							
						
					
					
						commit
						53dd45b740
					
				
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@ -108,8 +108,8 @@
 | 
			
		||||
import { mapGetters } from 'vuex'
 | 
			
		||||
import { socket } from '@/utils/socket'
 | 
			
		||||
import { showView } from '@js/tabs.js'
 | 
			
		||||
import Downloads from '@/utils/downloads'
 | 
			
		||||
import Utils from '@/utils/utils'
 | 
			
		||||
import { sendAddToQueue } from '@/utils/downloads'
 | 
			
		||||
import { convertDuration } from '@/utils/utils'
 | 
			
		||||
 | 
			
		||||
import { getChartsData } from '@/data/charts'
 | 
			
		||||
 | 
			
		||||
@ -124,38 +124,21 @@ export default {
 | 
			
		||||
			chart: []
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	computed: {
 | 
			
		||||
		...mapGetters(['getCharts']),
 | 
			
		||||
		needToWait() {
 | 
			
		||||
			return this.getCharts.length === 0
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	async created() {
 | 
			
		||||
		socket.on('setChartTracks', this.setTracklist)
 | 
			
		||||
		this.$on('hook:destroyed', () => {
 | 
			
		||||
			console.log('destroyed')
 | 
			
		||||
			socket.off('setChartTracks')
 | 
			
		||||
		})
 | 
			
		||||
 | 
			
		||||
		const chartsData = await getChartsData()
 | 
			
		||||
 | 
			
		||||
		this.initCharts(chartsData)
 | 
			
		||||
	},
 | 
			
		||||
	mounted() {
 | 
			
		||||
		socket.on('setChartTracks', this.setTracklist)
 | 
			
		||||
	},
 | 
			
		||||
	methods: {
 | 
			
		||||
		convertDuration,
 | 
			
		||||
		artistView: showView.bind(null, 'artist'),
 | 
			
		||||
		albumView: showView.bind(null, 'album'),
 | 
			
		||||
		waitCharts() {
 | 
			
		||||
			if (this.needToWait) {
 | 
			
		||||
				// Checking if the saving of the settings is completed
 | 
			
		||||
				let unsub = this.$store.subscribeAction({
 | 
			
		||||
					after: (action, state) => {
 | 
			
		||||
						if (action.type === 'cacheCharts') {
 | 
			
		||||
							this.initCharts()
 | 
			
		||||
							unsub()
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
				})
 | 
			
		||||
			} else {
 | 
			
		||||
				this.initCharts()
 | 
			
		||||
			}
 | 
			
		||||
		},
 | 
			
		||||
		playPausePreview(e) {
 | 
			
		||||
			EventBus.$emit('trackPreview:playPausePreview', e)
 | 
			
		||||
		},
 | 
			
		||||
@ -165,10 +148,9 @@ export default {
 | 
			
		||||
		previewMouseLeave(e) {
 | 
			
		||||
			EventBus.$emit('trackPreview:previewMouseLeave', e)
 | 
			
		||||
		},
 | 
			
		||||
		convertDuration: Utils.convertDuration,
 | 
			
		||||
		addToQueue(e) {
 | 
			
		||||
			e.stopPropagation()
 | 
			
		||||
			Downloads.sendAddToQueue(e.currentTarget.dataset.link)
 | 
			
		||||
			sendAddToQueue(e.currentTarget.dataset.link)
 | 
			
		||||
		},
 | 
			
		||||
		getTrackList(event) {
 | 
			
		||||
			document.getElementById('content').scrollTo(0, 0)
 | 
			
		||||
@ -188,6 +170,7 @@ export default {
 | 
			
		||||
			socket.emit('getChartTracks', this.id)
 | 
			
		||||
		},
 | 
			
		||||
		setTracklist(data) {
 | 
			
		||||
			console.log('set tracklist')
 | 
			
		||||
			this.chart = data
 | 
			
		||||
		},
 | 
			
		||||
		changeCountry() {
 | 
			
		||||
 | 
			
		||||
@ -78,10 +78,8 @@
 | 
			
		||||
<script>
 | 
			
		||||
import { mapGetters } from 'vuex'
 | 
			
		||||
 | 
			
		||||
import { socket } from '@/utils/socket'
 | 
			
		||||
import { showView } from '@js/tabs'
 | 
			
		||||
import Downloads from '@/utils/downloads'
 | 
			
		||||
 | 
			
		||||
import { sendAddToQueue } from '@/utils/downloads'
 | 
			
		||||
import { getHomeData } from '@/data/home'
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
@ -92,16 +90,12 @@ export default {
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	async created() {
 | 
			
		||||
		// if (localStorage.getItem('arl')) {
 | 
			
		||||
		// 	this.$refs.notLogged.classList.add('hide')
 | 
			
		||||
		// }
 | 
			
		||||
 | 
			
		||||
		const homeData = await getHomeData()
 | 
			
		||||
 | 
			
		||||
		this.initHome(homeData)
 | 
			
		||||
	},
 | 
			
		||||
	computed: {
 | 
			
		||||
		...mapGetters([/* 'getHomeData', */ 'isLoggedIn']),
 | 
			
		||||
		...mapGetters(['isLoggedIn']),
 | 
			
		||||
		needToWait() {
 | 
			
		||||
			return this.getHomeData.albums.data.length === 0 && this.getHomeData.playlists.data.length === 0
 | 
			
		||||
		}
 | 
			
		||||
@ -111,7 +105,7 @@ export default {
 | 
			
		||||
		albumView: showView.bind(null, 'album'),
 | 
			
		||||
		playlistView: showView.bind(null, 'playlist'),
 | 
			
		||||
		addToQueue(e) {
 | 
			
		||||
			Downloads.sendAddToQueue(e.currentTarget.dataset.link)
 | 
			
		||||
			sendAddToQueue(e.currentTarget.dataset.link)
 | 
			
		||||
		},
 | 
			
		||||
		initHome(data) {
 | 
			
		||||
			const {
 | 
			
		||||
@ -121,22 +115,6 @@ export default {
 | 
			
		||||
 | 
			
		||||
			this.playlists = playlistData
 | 
			
		||||
			this.albums = albumData
 | 
			
		||||
		},
 | 
			
		||||
		// ! Define this functionality as a Vue Mixin
 | 
			
		||||
		checkIfWaitData(data) {
 | 
			
		||||
			if (this.needToWait) {
 | 
			
		||||
				// This case verifies only at the first load, beacuse the data retrieving is not completed yet
 | 
			
		||||
				let unsub = this.$store.subscribeAction({
 | 
			
		||||
					after: (action, state) => {
 | 
			
		||||
						if (action.type === 'cacheHomeData') {
 | 
			
		||||
							this.initHome(this.getHomeData)
 | 
			
		||||
							unsub()
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
				})
 | 
			
		||||
			} else {
 | 
			
		||||
				this.initHome(this.getHomeData)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,11 +1,9 @@
 | 
			
		||||
import Vuex from 'vuex'
 | 
			
		||||
import Vue from 'vue'
 | 
			
		||||
 | 
			
		||||
// import home from '@/store/modules/home'
 | 
			
		||||
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 favorites from '@/store/modules/favorites'
 | 
			
		||||
import about from '@/store/modules/about'
 | 
			
		||||
import login from '@/store/modules/login'
 | 
			
		||||
@ -17,11 +15,9 @@ Vue.use(Vuex)
 | 
			
		||||
// Create store
 | 
			
		||||
export default new Vuex.Store({
 | 
			
		||||
	modules: {
 | 
			
		||||
		// home,
 | 
			
		||||
		settings,
 | 
			
		||||
		defaultSettings,
 | 
			
		||||
		spotifyCredentials,
 | 
			
		||||
		// charts,
 | 
			
		||||
		favorites,
 | 
			
		||||
		about,
 | 
			
		||||
		login,
 | 
			
		||||
 | 
			
		||||
@ -1,40 +0,0 @@
 | 
			
		||||
import Vue from 'vue'
 | 
			
		||||
 | 
			
		||||
const state = {
 | 
			
		||||
	list: []
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
let chartsCached = false
 | 
			
		||||
 | 
			
		||||
const actions = {
 | 
			
		||||
	/**
 | 
			
		||||
	 * @param {object} context
 | 
			
		||||
	 * @param {object[]} payload
 | 
			
		||||
	 */
 | 
			
		||||
	cacheCharts({ commit }, payload) {
 | 
			
		||||
		if (chartsCached) return
 | 
			
		||||
 | 
			
		||||
		payload.forEach((chartObj, index) => {
 | 
			
		||||
			commit('SET_UNKNOWN_CHART', { index, chartObj })
 | 
			
		||||
		})
 | 
			
		||||
 | 
			
		||||
		chartsCached = true
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const getters = {
 | 
			
		||||
	getCharts: state => state.list
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const mutations = {
 | 
			
		||||
	SET_UNKNOWN_CHART(state, payload) {
 | 
			
		||||
		Vue.set(state.list, payload.index, payload.chartObj)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
	state,
 | 
			
		||||
	getters,
 | 
			
		||||
	actions,
 | 
			
		||||
	mutations
 | 
			
		||||
}
 | 
			
		||||
@ -1,84 +0,0 @@
 | 
			
		||||
import Vue from 'vue'
 | 
			
		||||
 | 
			
		||||
const state = {
 | 
			
		||||
	albums: {
 | 
			
		||||
		data: [],
 | 
			
		||||
		total: 0
 | 
			
		||||
	},
 | 
			
		||||
	artists: {
 | 
			
		||||
		data: [],
 | 
			
		||||
		total: 0
 | 
			
		||||
	},
 | 
			
		||||
	playlists: {
 | 
			
		||||
		data: [],
 | 
			
		||||
		total: 0
 | 
			
		||||
	},
 | 
			
		||||
	podcasts: {
 | 
			
		||||
		data: [],
 | 
			
		||||
		total: 0
 | 
			
		||||
	},
 | 
			
		||||
	tracks: {
 | 
			
		||||
		data: [],
 | 
			
		||||
		total: 0
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
let homeDataCached = false
 | 
			
		||||
 | 
			
		||||
const actions = {
 | 
			
		||||
	cacheHomeData({ commit }, payload) {
 | 
			
		||||
		if (homeDataCached) return
 | 
			
		||||
 | 
			
		||||
		commit('SET_HOME_ALBUMS', payload.albums)
 | 
			
		||||
		commit('SET_HOME_ARTISTS', payload.artists)
 | 
			
		||||
		commit('SET_HOME_PLAYLISTS', payload.playlists)
 | 
			
		||||
		commit('SET_HOME_PODCASTS', payload.podcasts)
 | 
			
		||||
		commit('SET_HOME_TRACKS', payload.tracks)
 | 
			
		||||
 | 
			
		||||
		homeDataCached = true
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const getters = {
 | 
			
		||||
	getHomeData: state => state,
 | 
			
		||||
	getHomeAlbums: state => state.albums,
 | 
			
		||||
	getHomeArtists: state => state.artists,
 | 
			
		||||
	getHomePlaylists: state => state.playlists,
 | 
			
		||||
	getHomePodcasts: state => state.podcasts,
 | 
			
		||||
	getHomeTracks: state => state.tracks
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const mutations = {
 | 
			
		||||
	SET_HOME_ALBUMS: (state, payload) => {
 | 
			
		||||
		Vue.set(state.albums, 'data', payload.data)
 | 
			
		||||
		// state.albums.data = payload.data
 | 
			
		||||
		state.albums.total = payload.total
 | 
			
		||||
	},
 | 
			
		||||
	SET_HOME_ARTISTS: (state, payload) => {
 | 
			
		||||
		Vue.set(state.artists, 'data', payload.data)
 | 
			
		||||
		// state.artists.data = payload.data
 | 
			
		||||
		state.artists.total = payload.total
 | 
			
		||||
	},
 | 
			
		||||
	SET_HOME_PLAYLISTS: (state, payload) => {
 | 
			
		||||
		Vue.set(state.playlists, 'data', payload.data)
 | 
			
		||||
		// state.playlists.data = payload.data
 | 
			
		||||
		state.playlists.total = payload.total
 | 
			
		||||
	},
 | 
			
		||||
	SET_HOME_PODCASTS: (state, payload) => {
 | 
			
		||||
		Vue.set(state.podcasts, 'data', payload.data)
 | 
			
		||||
		// state.podcasts.data = payload.data
 | 
			
		||||
		state.podcasts.total = payload.total
 | 
			
		||||
	},
 | 
			
		||||
	SET_HOME_TRACKS: (state, payload) => {
 | 
			
		||||
		Vue.set(state.tracks, 'data', payload.data)
 | 
			
		||||
		// state.tracks.data = payload.data
 | 
			
		||||
		state.tracks.total = payload.total
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
	state,
 | 
			
		||||
	actions,
 | 
			
		||||
	getters,
 | 
			
		||||
	mutations
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user