From 55ee6361d67ff2c24e2e333d47bb25adea329f94 Mon Sep 17 00:00:00 2001 From: josdejong Date: Tue, 2 Jun 2020 14:13:33 +0200 Subject: [PATCH] Rename state constant names --- src/JSONEditor.svelte | 16 ++++++++-------- src/JSONNode.svelte | 22 +++++++++++----------- src/constants.js | 8 ++++---- src/utils/search.js | 14 +++++++------- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/JSONEditor.svelte b/src/JSONEditor.svelte index 670003d..e72d85e 100644 --- a/src/JSONEditor.svelte +++ b/src/JSONEditor.svelte @@ -2,8 +2,8 @@ import { tick } from 'svelte' import { DEFAULT_LIMIT, - EXPANDED_PROPERTY, - LIMIT_PROPERTY, + STATE_EXPANDED, + STATE_LIMIT, SCROLL_DURATION } from './constants.js' import SearchBox from './SearchBox.svelte' @@ -26,7 +26,7 @@ } const INITIAL_STATE = { - [EXPANDED_PROPERTY]: true + [STATE_EXPANDED]: true } let state = INITIAL_STATE @@ -196,7 +196,7 @@ * @param {boolean} expanded */ function handleExpand (path, expanded) { - state = setIn(state, path.concat(EXPANDED_PROPERTY), expanded) + state = setIn(state, path.concat(STATE_EXPANDED), expanded) } /** @@ -205,7 +205,7 @@ * @param {boolean} limit */ function handleLimit (path, limit) { - state = setIn(state, path.concat(LIMIT_PROPERTY), limit) + state = setIn(state, path.concat(STATE_LIMIT), limit) } /** @@ -215,15 +215,15 @@ function expandPath (path) { for (let i = 1; i < path.length; i++) { const partialPath = path.slice(0, i) - state = setIn(state, partialPath.concat(EXPANDED_PROPERTY), true) + state = setIn(state, partialPath.concat(STATE_EXPANDED), true) // if needed, enlarge the limit such that the search result becomes visible const key = path[i] if (isNumber(key)) { - const limit = getIn(state, partialPath.concat(LIMIT_PROPERTY)) || DEFAULT_LIMIT + const limit = getIn(state, partialPath.concat(STATE_LIMIT)) || DEFAULT_LIMIT if (key > limit) { const newLimit = Math.ceil(key / DEFAULT_LIMIT) * DEFAULT_LIMIT - state = setIn(state, partialPath.concat(LIMIT_PROPERTY), newLimit) + state = setIn(state, partialPath.concat(STATE_LIMIT), newLimit) } } } diff --git a/src/JSONNode.svelte b/src/JSONNode.svelte index 836b4f9..c390853 100644 --- a/src/JSONNode.svelte +++ b/src/JSONNode.svelte @@ -1,9 +1,9 @@