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 { mapGetters } from 'vuex'
|
||||||
import { socket } from '@/utils/socket'
|
import { socket } from '@/utils/socket'
|
||||||
import { showView } from '@js/tabs.js'
|
import { showView } from '@js/tabs.js'
|
||||||
import Downloads from '@/utils/downloads'
|
import { sendAddToQueue } from '@/utils/downloads'
|
||||||
import Utils from '@/utils/utils'
|
import { convertDuration } from '@/utils/utils'
|
||||||
|
|
||||||
import { getChartsData } from '@/data/charts'
|
import { getChartsData } from '@/data/charts'
|
||||||
|
|
||||||
@ -124,38 +124,21 @@ export default {
|
|||||||
chart: []
|
chart: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
|
||||||
...mapGetters(['getCharts']),
|
|
||||||
needToWait() {
|
|
||||||
return this.getCharts.length === 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async created() {
|
async created() {
|
||||||
|
socket.on('setChartTracks', this.setTracklist)
|
||||||
|
this.$on('hook:destroyed', () => {
|
||||||
|
console.log('destroyed')
|
||||||
|
socket.off('setChartTracks')
|
||||||
|
})
|
||||||
|
|
||||||
const chartsData = await getChartsData()
|
const chartsData = await getChartsData()
|
||||||
|
|
||||||
this.initCharts(chartsData)
|
this.initCharts(chartsData)
|
||||||
},
|
},
|
||||||
mounted() {
|
|
||||||
socket.on('setChartTracks', this.setTracklist)
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
|
convertDuration,
|
||||||
artistView: showView.bind(null, 'artist'),
|
artistView: showView.bind(null, 'artist'),
|
||||||
albumView: showView.bind(null, 'album'),
|
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) {
|
playPausePreview(e) {
|
||||||
EventBus.$emit('trackPreview:playPausePreview', e)
|
EventBus.$emit('trackPreview:playPausePreview', e)
|
||||||
},
|
},
|
||||||
@ -165,10 +148,9 @@ export default {
|
|||||||
previewMouseLeave(e) {
|
previewMouseLeave(e) {
|
||||||
EventBus.$emit('trackPreview:previewMouseLeave', e)
|
EventBus.$emit('trackPreview:previewMouseLeave', e)
|
||||||
},
|
},
|
||||||
convertDuration: Utils.convertDuration,
|
|
||||||
addToQueue(e) {
|
addToQueue(e) {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
Downloads.sendAddToQueue(e.currentTarget.dataset.link)
|
sendAddToQueue(e.currentTarget.dataset.link)
|
||||||
},
|
},
|
||||||
getTrackList(event) {
|
getTrackList(event) {
|
||||||
document.getElementById('content').scrollTo(0, 0)
|
document.getElementById('content').scrollTo(0, 0)
|
||||||
@ -188,6 +170,7 @@ export default {
|
|||||||
socket.emit('getChartTracks', this.id)
|
socket.emit('getChartTracks', this.id)
|
||||||
},
|
},
|
||||||
setTracklist(data) {
|
setTracklist(data) {
|
||||||
|
console.log('set tracklist')
|
||||||
this.chart = data
|
this.chart = data
|
||||||
},
|
},
|
||||||
changeCountry() {
|
changeCountry() {
|
||||||
|
@ -78,10 +78,8 @@
|
|||||||
<script>
|
<script>
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
|
|
||||||
import { socket } from '@/utils/socket'
|
|
||||||
import { showView } from '@js/tabs'
|
import { showView } from '@js/tabs'
|
||||||
import Downloads from '@/utils/downloads'
|
import { sendAddToQueue } from '@/utils/downloads'
|
||||||
|
|
||||||
import { getHomeData } from '@/data/home'
|
import { getHomeData } from '@/data/home'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -92,16 +90,12 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async created() {
|
async created() {
|
||||||
// if (localStorage.getItem('arl')) {
|
|
||||||
// this.$refs.notLogged.classList.add('hide')
|
|
||||||
// }
|
|
||||||
|
|
||||||
const homeData = await getHomeData()
|
const homeData = await getHomeData()
|
||||||
|
|
||||||
this.initHome(homeData)
|
this.initHome(homeData)
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters([/* 'getHomeData', */ 'isLoggedIn']),
|
...mapGetters(['isLoggedIn']),
|
||||||
needToWait() {
|
needToWait() {
|
||||||
return this.getHomeData.albums.data.length === 0 && this.getHomeData.playlists.data.length === 0
|
return this.getHomeData.albums.data.length === 0 && this.getHomeData.playlists.data.length === 0
|
||||||
}
|
}
|
||||||
@ -111,7 +105,7 @@ export default {
|
|||||||
albumView: showView.bind(null, 'album'),
|
albumView: showView.bind(null, 'album'),
|
||||||
playlistView: showView.bind(null, 'playlist'),
|
playlistView: showView.bind(null, 'playlist'),
|
||||||
addToQueue(e) {
|
addToQueue(e) {
|
||||||
Downloads.sendAddToQueue(e.currentTarget.dataset.link)
|
sendAddToQueue(e.currentTarget.dataset.link)
|
||||||
},
|
},
|
||||||
initHome(data) {
|
initHome(data) {
|
||||||
const {
|
const {
|
||||||
@ -121,22 +115,6 @@ export default {
|
|||||||
|
|
||||||
this.playlists = playlistData
|
this.playlists = playlistData
|
||||||
this.albums = albumData
|
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 Vuex from 'vuex'
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
|
||||||
// import home from '@/store/modules/home'
|
|
||||||
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 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'
|
||||||
@ -17,11 +15,9 @@ Vue.use(Vuex)
|
|||||||
// Create store
|
// Create store
|
||||||
export default new Vuex.Store({
|
export default new Vuex.Store({
|
||||||
modules: {
|
modules: {
|
||||||
// home,
|
|
||||||
settings,
|
settings,
|
||||||
defaultSettings,
|
defaultSettings,
|
||||||
spotifyCredentials,
|
spotifyCredentials,
|
||||||
// charts,
|
|
||||||
favorites,
|
favorites,
|
||||||
about,
|
about,
|
||||||
login,
|
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…
Reference in New Issue
Block a user