diff --git a/src/components/wired/views/WiredBaseView.tsx b/src/components/wired/views/WiredBaseView.tsx index fd862e89..c8f3ca79 100644 --- a/src/components/wired/views/WiredBaseView.tsx +++ b/src/components/wired/views/WiredBaseView.tsx @@ -19,21 +19,28 @@ export const WiredBaseView: FC = props => const { wiredType = '', requiresFurni = WiredFurniType.STUFF_SELECTION_OPTION_NONE, save = null, validate = null, children = null, hasSpecialInput = false } = props; const [ wiredName, setWiredName ] = useState(null); const [ wiredDescription, setWiredDescription ] = useState(null); + const [ needsSave, setNeedsSave ] = useState(false); const { trigger = null, setTrigger = null, setIntParams = null, setStringParam = null, setFurniIds = null, saveWired = null } = useWiredContext(); + const close = () => setTrigger(null); + const onSave = () => { if(validate && !validate()) return; if(save) save(); - saveWired(); + setNeedsSave(true); } - const close = () => + useEffect(() => { - setTrigger(null); - } + if(!needsSave) return; + + saveWired(); + + setNeedsSave(false); + }, [ needsSave, saveWired ]); useEffect(() => { @@ -83,6 +90,7 @@ export const WiredBaseView: FC = props => { BatchUpdates(() => { + setNeedsSave(false); setIntParams([]); setStringParam(null); setFurniIds(prevValue =>