mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-23 14:40:50 +01:00
Fix wired saving
This commit is contained in:
parent
3990edd710
commit
93a63e05ed
@ -19,21 +19,28 @@ export const WiredBaseView: FC<WiredBaseViewProps> = props =>
|
|||||||
const { wiredType = '', requiresFurni = WiredFurniType.STUFF_SELECTION_OPTION_NONE, save = null, validate = null, children = null, hasSpecialInput = false } = props;
|
const { wiredType = '', requiresFurni = WiredFurniType.STUFF_SELECTION_OPTION_NONE, save = null, validate = null, children = null, hasSpecialInput = false } = props;
|
||||||
const [ wiredName, setWiredName ] = useState<string>(null);
|
const [ wiredName, setWiredName ] = useState<string>(null);
|
||||||
const [ wiredDescription, setWiredDescription ] = useState<string>(null);
|
const [ wiredDescription, setWiredDescription ] = useState<string>(null);
|
||||||
|
const [ needsSave, setNeedsSave ] = useState<boolean>(false);
|
||||||
const { trigger = null, setTrigger = null, setIntParams = null, setStringParam = null, setFurniIds = null, saveWired = null } = useWiredContext();
|
const { trigger = null, setTrigger = null, setIntParams = null, setStringParam = null, setFurniIds = null, saveWired = null } = useWiredContext();
|
||||||
|
|
||||||
|
const close = () => setTrigger(null);
|
||||||
|
|
||||||
const onSave = () =>
|
const onSave = () =>
|
||||||
{
|
{
|
||||||
if(validate && !validate()) return;
|
if(validate && !validate()) return;
|
||||||
|
|
||||||
if(save) save();
|
if(save) save();
|
||||||
|
|
||||||
saveWired();
|
setNeedsSave(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
const close = () =>
|
useEffect(() =>
|
||||||
{
|
{
|
||||||
setTrigger(null);
|
if(!needsSave) return;
|
||||||
}
|
|
||||||
|
saveWired();
|
||||||
|
|
||||||
|
setNeedsSave(false);
|
||||||
|
}, [ needsSave, saveWired ]);
|
||||||
|
|
||||||
useEffect(() =>
|
useEffect(() =>
|
||||||
{
|
{
|
||||||
@ -83,6 +90,7 @@ export const WiredBaseView: FC<WiredBaseViewProps> = props =>
|
|||||||
{
|
{
|
||||||
BatchUpdates(() =>
|
BatchUpdates(() =>
|
||||||
{
|
{
|
||||||
|
setNeedsSave(false);
|
||||||
setIntParams([]);
|
setIntParams([]);
|
||||||
setStringParam(null);
|
setStringParam(null);
|
||||||
setFurniIds(prevValue =>
|
setFurniIds(prevValue =>
|
||||||
|
Loading…
Reference in New Issue
Block a user