diff --git a/src/components/avatar-editor/AvatarEditorView.tsx b/src/components/avatar-editor/AvatarEditorView.tsx index 82f37790..98aa2d81 100644 --- a/src/components/avatar-editor/AvatarEditorView.tsx +++ b/src/components/avatar-editor/AvatarEditorView.tsx @@ -37,7 +37,7 @@ export const AvatarEditorView: FC<{}> = props => const [ isWardrobeVisible, setIsWardrobeVisible ] = useState(false); const [ lastFigure, setLastFigure ] = useState(null); const [ lastGender, setLastGender ] = useState(null); - const [ needsReset, setNeedsReset ] = useState(false); + const [ needsReset, setNeedsReset ] = useState(true); const [ isInitalized, setIsInitalized ] = useState(false); const maxWardrobeSlots = useMemo(() => GetConfiguration('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 (