Replaced coalesce with real ?? operator

This commit is contained in:
Travis Shivers 2020-06-30 01:20:26 -05:00
parent f8afae8b3c
commit 5c860b322b
2 changed files with 15 additions and 31 deletions

View File

@ -1,39 +1,26 @@
import coalesce from '@/utils/coalesce';
// Use stored value if not null, othewise fallback to config, then default values
export default {
GET_AUTOPLAY: (state, getters, rootState, rootGetters) => coalesce(state.autoplay,
rootGetters.GET_CONFIG.default_slplayer_autoplay),
GET_AUTOPLAY: (state, getters, rootState, rootGetters) => state.autoplay
?? rootGetters.GET_CONFIG.default_slplayer_autoplay,
GET_CLIENTPOLLINTERVAL: (state, getters, rootState, rootGetters) => coalesce(
state.clientPollInterval,
rootGetters.GET_CONFIG.default_client_poll_interval,
),
GET_CLIENTPOLLINTERVAL: (state, getters, rootState, rootGetters) => state.clientPollInterval
?? rootGetters.GET_CONFIG.default_client_poll_interval,
GET_SYNCMODE: (state, getters, rootState, rootGetters) => coalesce(
state.syncMode,
rootGetters.GET_CONFIG.default_sync_mode,
),
GET_SYNCMODE: (state, getters, rootState, rootGetters) => state.syncMode
?? rootGetters.GET_CONFIG.default_sync_mode,
GET_SYNCFLEXIBILITY: (state, getters, rootState, rootGetters) => coalesce(
state.syncFlexibility,
rootGetters.GET_CONFIG.default_sync_flexability,
),
GET_SYNCFLEXIBILITY: (state, getters, rootState, rootGetters) => state.syncFlexibility
?? rootGetters.GET_CONFIG.default_sync_flexability,
GET_SLPLAYERQUALITY: (state, getters, rootState, rootGetters) => coalesce(
state.slPlayerQuality,
rootGetters.GET_CONFIG.default_slplayer_quality,
) || null,
GET_SLPLAYERQUALITY: (state, getters, rootState, rootGetters) => state.slPlayerQuality
?? rootGetters.GET_CONFIG.default_slplayer_quality ?? null,
GET_SLPLAYERVOLUME: (state, getters, rootState, rootGetters) => coalesce(
state.slPlayerVolume,
rootGetters.GET_CONFIG.default_slplayer_volume,
),
GET_SLPLAYERVOLUME: (state, getters, rootState, rootGetters) => state.slPlayerVolume
?? rootGetters.GET_CONFIG.default_slplayer_volume,
GET_SLPLAYERFORCETRANSCODE: (state, getters, rootState, rootGetters) => coalesce(
state.slPlayerForceTranscode,
rootGetters.GET_CONFIG.default_slplayer_force_transcode,
),
GET_SLPLAYERFORCETRANSCODE: (state, getters, rootState, rootGetters) => state
.slPlayerForceTranscode
?? rootGetters.GET_CONFIG.default_slplayer_force_transcode,
GET_HIDEUSERNAME: (state) => state.hideUsername,
GET_ALTUSERNAME: (state) => state.altUsername,

View File

@ -1,3 +0,0 @@
const coalesce = (...arr) => arr.find((element) => element !== null && element !== undefined);
export default coalesce;