mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-26 15:40:51 +01:00
Fix wired furni selection
This commit is contained in:
parent
7c68755014
commit
b084ba6210
@ -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 }>
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user