From 5c860b322b6155eb27998b16de4b050272a7b72b Mon Sep 17 00:00:00 2001 From: Travis Shivers Date: Tue, 30 Jun 2020 01:20:26 -0500 Subject: [PATCH] Replaced coalesce with real ?? operator --- src/store/modules/settings/getters.js | 43 ++++++++++----------------- src/utils/coalesce.js | 3 -- 2 files changed, 15 insertions(+), 31 deletions(-) delete mode 100644 src/utils/coalesce.js diff --git a/src/store/modules/settings/getters.js b/src/store/modules/settings/getters.js index 3451fc74..e16bf3fd 100644 --- a/src/store/modules/settings/getters.js +++ b/src/store/modules/settings/getters.js @@ -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, diff --git a/src/utils/coalesce.js b/src/utils/coalesce.js deleted file mode 100644 index 6b54b9ff..00000000 --- a/src/utils/coalesce.js +++ /dev/null @@ -1,3 +0,0 @@ -const coalesce = (...arr) => arr.find((element) => element !== null && element !== undefined); - -export default coalesce;