mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-20 15:36:18 +00:00
feat(wired-ui): expand advanced wired editors
This commit is contained in:
@@ -4,13 +4,16 @@ import { Text } from '../../../../common';
|
||||
import { useWired } from '../../../../hooks';
|
||||
import { NitroInput } from '../../../../layout';
|
||||
import { WiredActionBaseView } from './WiredActionBaseView';
|
||||
import { WiredSourcesSelector } from '../WiredSourcesSelector';
|
||||
import { BOT_SOURCES, WiredSourcesSelector } from '../WiredSourcesSelector';
|
||||
|
||||
const normalizeBotSource = (value: number, hasBotName = false) => (BOT_SOURCES.some(option => (option.value === value)) ? value : (hasBotName ? 100 : 0));
|
||||
|
||||
export const WiredActionBotFollowAvatarView: FC<{}> = props =>
|
||||
{
|
||||
const [ botName, setBotName ] = useState('');
|
||||
const [ followMode, setFollowMode ] = useState(-1);
|
||||
const { trigger = null, setStringParam = null, setIntParams = null } = useWired();
|
||||
const [ botSource, setBotSource ] = useState<number>(100);
|
||||
const [ userSource, setUserSource ] = useState<number>(() =>
|
||||
{
|
||||
if(trigger?.intData?.length > 1) return trigger.intData[1];
|
||||
@@ -19,15 +22,17 @@ export const WiredActionBotFollowAvatarView: FC<{}> = props =>
|
||||
|
||||
const save = () =>
|
||||
{
|
||||
setStringParam(botName);
|
||||
setIntParams([ followMode, userSource ]);
|
||||
setStringParam((botSource === 100) ? botName : '');
|
||||
setIntParams([ followMode, userSource, botSource ]);
|
||||
};
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
setBotName(trigger.stringData);
|
||||
const nextBotName = trigger.stringData || '';
|
||||
setBotName(nextBotName);
|
||||
setFollowMode((trigger.intData.length > 0) ? trigger.intData[0] : 0);
|
||||
setUserSource((trigger.intData.length > 1) ? trigger.intData[1] : 0);
|
||||
setBotSource((trigger.intData.length > 2) ? normalizeBotSource(trigger.intData[2], (nextBotName.length > 0)) : normalizeBotSource(-1, (nextBotName.length > 0)));
|
||||
}, [ trigger ]);
|
||||
|
||||
return (
|
||||
@@ -35,11 +40,18 @@ export const WiredActionBotFollowAvatarView: FC<{}> = props =>
|
||||
hasSpecialInput={ true }
|
||||
requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE }
|
||||
save={ save }
|
||||
footer={ <WiredSourcesSelector showUsers={ true } userSource={ userSource } onChangeUsers={ setUserSource } /> }>
|
||||
<div className="flex flex-col gap-1">
|
||||
<Text bold>{ LocalizeText('wiredfurni.params.bot.name') }</Text>
|
||||
<NitroInput maxLength={ 32 } type="text" value={ botName } onChange={ event => setBotName(event.target.value) } />
|
||||
</div>
|
||||
footer={
|
||||
<div className="flex flex-col gap-2">
|
||||
<WiredSourcesSelector showUsers={ true } userSource={ userSource } onChangeUsers={ setUserSource } />
|
||||
<hr className="m-0 bg-dark" />
|
||||
<WiredSourcesSelector showUsers={ true } userSource={ botSource } userSources={ BOT_SOURCES } usersTitle="wiredfurni.params.sources.users.title.bots" onChangeUsers={ value => setBotSource(normalizeBotSource(value, (botName.length > 0))) } />
|
||||
</div>
|
||||
}>
|
||||
{ (botSource === 100) &&
|
||||
<div className="flex flex-col gap-1">
|
||||
<Text bold>{ LocalizeText('wiredfurni.params.bot.name') }</Text>
|
||||
<NitroInput maxLength={ 32 } type="text" value={ botName } onChange={ event => setBotName(event.target.value) } />
|
||||
</div> }
|
||||
<div className="flex flex-col gap-1">
|
||||
<div className="flex items-center gap-1">
|
||||
<input checked={ (followMode === 1) } className="form-check-input" id="followMode1" name="followMode" type="radio" onChange={ event => setFollowMode(1) } />
|
||||
|
||||
Reference in New Issue
Block a user