mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-23 06:40:50 +01:00
Reset figure on avatar editor toggle
This commit is contained in:
parent
830db963d7
commit
2796abc718
@ -37,7 +37,7 @@ export const AvatarEditorView: FC<{}> = props =>
|
||||
const [ isWardrobeVisible, setIsWardrobeVisible ] = useState(false);
|
||||
const [ lastFigure, setLastFigure ] = useState<string>(null);
|
||||
const [ lastGender, setLastGender ] = useState<string>(null);
|
||||
const [ needsReset, setNeedsReset ] = useState(false);
|
||||
const [ needsReset, setNeedsReset ] = useState(true);
|
||||
const [ isInitalized, setIsInitalized ] = useState(false);
|
||||
|
||||
const maxWardrobeSlots = useMemo(() => GetConfiguration<number>('avatar.wardrobe.max.slots', 10), []);
|
||||
@ -180,14 +180,7 @@ export const AvatarEditorView: FC<{}> = props =>
|
||||
setIsVisible(false);
|
||||
return;
|
||||
case 'toggle':
|
||||
setIsVisible(prevValue =>
|
||||
{
|
||||
const flag = !prevValue;
|
||||
|
||||
if(flag) setNeedsReset(true);
|
||||
|
||||
return flag;
|
||||
});
|
||||
setIsVisible(prevValue => !prevValue);
|
||||
return;
|
||||
}
|
||||
}, []);
|
||||
@ -278,6 +271,16 @@ export const AvatarEditorView: FC<{}> = props =>
|
||||
setNeedsReset(false);
|
||||
}, [ isVisible, isInitalized, needsReset, loadAvatarInEditor ]);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
if(isVisible) return;
|
||||
|
||||
return () =>
|
||||
{
|
||||
setNeedsReset(true);
|
||||
}
|
||||
}, [ isVisible ]);
|
||||
|
||||
if(!isVisible || !figureData) return null;
|
||||
|
||||
return (
|
||||
|
Loading…
Reference in New Issue
Block a user