diff --git a/configure/src/components/Tabs/Layers/Layers.js b/configure/src/components/Tabs/Layers/Layers.js index 6fff2476..74f66a6a 100644 --- a/configure/src/components/Tabs/Layers/Layers.js +++ b/configure/src/components/Tabs/Layers/Layers.js @@ -6,6 +6,7 @@ import { makeStyles } from "@mui/styles"; import clsx from "clsx"; import { reorderArray, insertLayerAfterUUID } from "../../../core/utils"; +import ConfigureStore from "../../../core/ConfigureStore"; import { setModal, setConfiguration } from "../../../core/ConfigureStore"; import LayerModal from "./Modals/LayerModal/LayerModal"; @@ -163,7 +164,8 @@ const useStyles = makeStyles((theme) => ({ }, })); -let savedLayersConfiguration = ""; +let configuration = {}; +let savedMinLayers = ""; export default function Layers() { const c = useStyles(); @@ -171,11 +173,30 @@ export default function Layers() { const [flatLayers, setFlatLayers] = useState([]); const mission = useSelector((state) => state.core.mission); - const configuration = useSelector((state) => state.core.configuration); + const minLayersStr = useSelector((state) => { + if (state.core.configuration?.layers == null) return "[]"; + + configuration = state.core.configuration; + + const minLayers = []; + traverseLayers(state.core.configuration.layers, (layer, path, i, depth) => { + minLayers.push({ + layer: { + name: layer.name, + uuid: layer.uuid, + type: layer.type, + visibility: layer.visibility, + }, + depth, + }); + }); + return JSON.stringify(minLayers); + }); + const minLayers = JSON.parse(minLayersStr); useEffect(() => { return () => { - savedLayersConfiguration = ""; + savedMinLayers = ""; }; }, []); @@ -194,14 +215,14 @@ export default function Layers() { return
Not found
; } - const strConf = JSON.stringify(configuration.layers); - if (savedLayersConfiguration != strConf) { + const strConf = JSON.stringify(minLayers); + if (savedMinLayers != strConf) { const nextFlatLayers = []; traverseLayers(configuration.layers, (layer, path, i, depth) => { nextFlatLayers.push({ layer, depth }); }); setFlatLayers(nextFlatLayers); - savedLayersConfiguration = strConf; + savedMinLayers = strConf; } const onIndent = (layer, idx) => { diff --git a/configure/src/core/utils.js b/configure/src/core/utils.js index 6f1ff832..4f41d6ec 100644 --- a/configure/src/core/utils.js +++ b/configure/src/core/utils.js @@ -27,6 +27,11 @@ export const setIn = (obj, keyArray, value, force) => { let object = obj; for (let i = 0; i < keyArray.length - 1; i++) { if (force) { + // If string but setting a number index at the end of keyArray, turn into array + if (i === keyArray.length - 2) { + if (isNumeric(keyArray[i + 1]) && !Array.isArray(object[keyArray[i]])) + object[keyArray[i]] = Array(object[keyArray[i]]); + } if (!object.hasOwnProperty(keyArray[i])) object[keyArray[i]] = i === keyArray.length - 2 && isNumeric(keyArray[i + 1]) ? [] : {}; diff --git a/docs/pages/Setup/ENVs/ENVs.md b/docs/pages/Setup/ENVs/ENVs.md index a12cb929..670fade8 100644 --- a/docs/pages/Setup/ENVs/ENVs.md +++ b/docs/pages/Setup/ENVs/ENVs.md @@ -62,7 +62,7 @@ Password of Postgres database | string | default `null` #### `PORT=` -Port to run on | positive integer | default `3000` +Port to run on | positive integer | default `8888` #### `DB_POOL_MAX=`