Fix wired furni selection

This commit is contained in:
Bill 2022-08-08 13:31:46 -04:00
parent 7c68755014
commit b084ba6210
2 changed files with 15 additions and 4 deletions

View File

@ -1,11 +1,21 @@
import { FC } from 'react';
import { FC, useEffect } from 'react';
import { LocalizeText } from '../../../api';
import { Column, Text } from '../../../common';
import { useWired } from '../../../hooks';
export const WiredFurniSelectorView: FC<{}> = props =>
{
const { trigger = null, furniIds = [] } = useWired();
const { trigger = null, furniIds = [], setAllowsFurni = null } = useWired();
useEffect(() =>
{
setAllowsFurni(true);
return () =>
{
setAllowsFurni(false);
}
}, [ setAllowsFurni ]);
return (
<Column gap={ 1 }>

View File

@ -12,6 +12,7 @@ const useWiredState = () =>
const [ stringParam, setStringParam ] = useState<string>('');
const [ furniIds, setFurniIds ] = useState<number[]>([]);
const [ actionDelay, setActionDelay ] = useState<number>(0);
const [ allowsFurni, setAllowsFurni ] = useState(false);
const { showConfirm = null } = useNotification();
const saveWired = () =>
@ -51,7 +52,7 @@ const useWiredState = () =>
const selectObjectForWired = (objectId: number, category: number) =>
{
if(!trigger) return;
if(!trigger || !allowsFurni) return;
if(objectId <= 0) return;
@ -125,7 +126,7 @@ const useWiredState = () =>
}
}, [ trigger ]);
return { trigger, setTrigger, intParams, setIntParams, stringParam, setStringParam, furniIds, setFurniIds, actionDelay, setActionDelay, saveWired, selectObjectForWired };
return { trigger, setTrigger, intParams, setIntParams, stringParam, setStringParam, furniIds, setFurniIds, actionDelay, setActionDelay, setAllowsFurni, saveWired, selectObjectForWired };
}
export const useWired = () => useBetween(useWiredState);