Refactor: Add setDfxUploaded to useDfxUpload hook and update useEffect to reset uploaded data on toggle view change
This commit is contained in:
@@ -17,7 +17,7 @@ import { useSceneContext } from '../../scene/sceneContext';
|
||||
*/
|
||||
const DxfFile = () => {
|
||||
// State management hooks
|
||||
const { dfxuploaded, dfxWallGenerate, setObjValue, objValue } = useDfxUpload();
|
||||
const { dfxuploaded, dfxWallGenerate, setObjValue, objValue, setDfxUploaded } = useDfxUpload();
|
||||
const { toggleView } = useToggleView();
|
||||
const { socket } = useSocketStore();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
@@ -31,13 +31,13 @@ const DxfFile = () => {
|
||||
const { wallStore } = useSceneContext();
|
||||
const { addWall, } = wallStore();
|
||||
const { walls } = wallStore();
|
||||
|
||||
|
||||
/**
|
||||
* Effect hook that runs when DXF wall generation is triggered.
|
||||
* Loads initial points and lines from the DXF data and updates the scene.
|
||||
*/
|
||||
useEffect(() => {
|
||||
|
||||
|
||||
if (dfxWallGenerate) {
|
||||
dfxWallGenerate.map((wall: Wall) => {
|
||||
const data = {
|
||||
@@ -80,7 +80,11 @@ const DxfFile = () => {
|
||||
wallThickness, wallHeight, outsideMaterial, insideMaterial, activeLayer, addWall, walls
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!toggleView) {
|
||||
setDfxUploaded([])
|
||||
}
|
||||
}, [toggleView])
|
||||
return (
|
||||
<>
|
||||
{/* Render DXF lines with transform controls when DXF data is available and view is toggled */}
|
||||
|
||||
Reference in New Issue
Block a user