chore: removed unused store files; fix: removed global window.vol object in favor to a store property; chore: changed store module aboutInfo to appInfo

This commit is contained in:
Roberto Tonino
2020-11-10 21:07:25 +01:00
parent 333af201e0
commit 86e3cda64c
13 changed files with 145 additions and 148 deletions

View File

@@ -1,17 +1,15 @@
import Vuex from 'vuex'
import Vue from 'vue'
import about from '@/store/modules/about'
import appInfo from '@/store/modules/appInfo'
import login from '@/store/modules/login'
import errors from '@/store/modules/errors'
// Load Vuex
Vue.use(Vuex)
// Create store
export default new Vuex.Store({
modules: {
about,
appInfo,
login,
errors
},

View File

@@ -1,41 +0,0 @@
const state = {
currentCommit: null,
latestCommit: null,
updateAvailable: false,
deemixVersion: null
}
const actions = {
setAboutInfo({ commit }, payload) {
commit('SET_CURRENT_COMMIT', payload.currentCommit)
commit('SET_LATEST_COMMIT', payload.latestCommit)
commit('SET_UPDATE_AVAILABLE', payload.updateAvailable)
commit('SET_DEEMIX_VERSION', payload.deemixVersion)
}
}
const getters = {
getAboutInfo: state => state
}
const mutations = {
SET_CURRENT_COMMIT: (state, payload) => {
state.currentCommit = payload
},
SET_LATEST_COMMIT: (state, payload) => {
state.latestCommit = payload
},
SET_UPDATE_AVAILABLE: (state, payload) => {
state.updateAvailable = payload
},
SET_DEEMIX_VERSION: (state, payload) => {
state.deemixVersion = payload
}
}
export default {
state,
getters,
actions,
mutations
}

View File

@@ -0,0 +1,98 @@
/**
* @typedef {object} AppInfo
* @property {string} currentCommit
* @property {string} latestCommit
* @property {boolean} updateAvailable
* @property {string} deemixVersion
* @property {number} previewVolume
*/
/**
* @returns {AppInfo}
*/
const state = () => ({
currentCommit: null,
latestCommit: null,
updateAvailable: false,
deemixVersion: null,
previewVolume: Number(localStorage.getItem('previewVolume')) || 100
})
const actions = {
/**
* @param {any} action
* @param {AppInfo} payload
*/
setAppInfo({ commit }, payload) {
commit('SET_CURRENT_COMMIT', payload.currentCommit)
commit('SET_LATEST_COMMIT', payload.latestCommit)
commit('SET_UPDATE_AVAILABLE', payload.updateAvailable)
commit('SET_DEEMIX_VERSION', payload.deemixVersion)
},
/**
* @param {any} action
* @param {AppInfo['previewVolume']} payload
*/
setPreviewVolume({ commit }, payload) {
commit('SET_PREVIEW_VOLUME', payload)
localStorage.setItem('previewVolume', payload.toString())
}
}
const getters = {
/**
* @param {AppInfo} state
* @returns {AppInfo}
*/
getAppInfo: state => state,
/**
* @param {AppInfo} state
* @returns {AppInfo['previewVolume']}
*/
getPreviewVolume: state => state.previewVolume
}
const mutations = {
/**
* @param {AppInfo} state
* @param {AppInfo['currentCommit']} payload
*/
SET_CURRENT_COMMIT(state, payload) {
state.currentCommit = payload
},
/**
* @param {AppInfo} state
* @param {AppInfo['latestCommit']} payload
*/
SET_LATEST_COMMIT(state, payload) {
state.latestCommit = payload
},
/**
* @param {AppInfo} state
* @param {AppInfo['updateAvailable']} payload
*/
SET_UPDATE_AVAILABLE(state, payload) {
state.updateAvailable = payload
},
/**
* @param {AppInfo} state
* @param {AppInfo['deemixVersion']} payload
*/
SET_DEEMIX_VERSION(state, payload) {
state.deemixVersion = payload
},
/**
* @param {AppInfo} state
* @param {AppInfo['previewVolume']} payload
*/
SET_PREVIEW_VOLUME(state, payload) {
state.previewVolume = payload
}
}
export default {
state,
getters,
actions,
mutations
}

View File

@@ -1,31 +0,0 @@
import Vue from 'vue'
const state = {}
const actions = {
setDefaultSettings({ commit }, payload) {
for (const settingName in payload) {
if (!payload.hasOwnProperty(settingName)) return
const settingValue = payload[settingName]
commit('SET_UNKNOWN_DEFAULT_SETTING', { settingName, settingValue })
}
}
}
const getters = {
getDefaultSettings: state => state
}
const mutations = {
SET_UNKNOWN_DEFAULT_SETTING(state, payload) {
Vue.set(state, payload.settingName, payload.settingValue)
}
}
export default {
state,
actions,
getters,
mutations
}

View File

@@ -1,4 +1,4 @@
const state = {
const state = () => ({
artist: '',
bitrate: '',
cover: '',
@@ -12,7 +12,7 @@ const state = {
title: '',
type: '',
uuid: ''
}
})
const actions = {
setErrors({ commit }, payload) {

View File

@@ -1,15 +1,13 @@
const getDefaultState = () => {
return {
arl: localStorage.getItem('arl') || '',
status: null,
user: {
id: null,
name: '',
picture: ''
},
clientMode: false
}
}
const getDefaultState = () => ({
arl: localStorage.getItem('arl') || '',
status: null,
user: {
id: null,
name: '',
picture: ''
},
clientMode: false
})
const state = getDefaultState()

View File

@@ -1,31 +0,0 @@
const state = {
clientId: '',
clientSecret: ''
}
const actions = {
setCredentials({ commit }, payload) {
commit('SET_CLIENT_ID', payload.clientId)
commit('SET_CLIENT_SECRET', payload.clientSecret)
}
}
const getters = {
getCredentials: state => state
}
const mutations = {
SET_CLIENT_ID(state, payload) {
state.clientId = payload
},
SET_CLIENT_SECRET(state, payload) {
state.clientSecret = payload
}
}
export default {
state,
getters,
actions,
mutations
}