import types from '../mutation-types'
import socket from '../../scripts/socket'
// import socket from '../../scripts/socket'

// Initial state
const state = {
  startedRefreshed: false
}

// Getters
const getters = {

}

// Actions
const actions = {
  restartApplication ({commit, state}) {
    socket.emit(`${types.settings.namespace}/${types.settings.events.refreshApplication}`)
  },

  changeVolume({commit, state}, newVolume) {
    //console.log(`volume change event, new volume: ${newVolume}`);
    socket.emit(types.volume, newVolume)
  }
}

// Mutations
const mutations = {

  [types.settings.events.startedRefreshed] (state, data) {
    state.startedRefreshed = !state.startedRefreshed
  },

  ['masterVolume'] (state, data) {
    state.masterVolume = data;
  }

}

export default {
  namespaced: true,
  state,
  getters,
  actions,
  mutations
}
