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