Reset figure on avatar editor toggle

This commit is contained in:
Bill 2022-03-16 23:19:01 -04:00
parent 830db963d7
commit 2796abc718

View File

@ -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 (