mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-27 08:00:51 +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 [ isWardrobeVisible, setIsWardrobeVisible ] = useState(false);
|
||||||
const [ lastFigure, setLastFigure ] = useState<string>(null);
|
const [ lastFigure, setLastFigure ] = useState<string>(null);
|
||||||
const [ lastGender, setLastGender ] = 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 [ isInitalized, setIsInitalized ] = useState(false);
|
||||||
|
|
||||||
const maxWardrobeSlots = useMemo(() => GetConfiguration<number>('avatar.wardrobe.max.slots', 10), []);
|
const maxWardrobeSlots = useMemo(() => GetConfiguration<number>('avatar.wardrobe.max.slots', 10), []);
|
||||||
@ -180,14 +180,7 @@ export const AvatarEditorView: FC<{}> = props =>
|
|||||||
setIsVisible(false);
|
setIsVisible(false);
|
||||||
return;
|
return;
|
||||||
case 'toggle':
|
case 'toggle':
|
||||||
setIsVisible(prevValue =>
|
setIsVisible(prevValue => !prevValue);
|
||||||
{
|
|
||||||
const flag = !prevValue;
|
|
||||||
|
|
||||||
if(flag) setNeedsReset(true);
|
|
||||||
|
|
||||||
return flag;
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
@ -278,6 +271,16 @@ export const AvatarEditorView: FC<{}> = props =>
|
|||||||
setNeedsReset(false);
|
setNeedsReset(false);
|
||||||
}, [ isVisible, isInitalized, needsReset, loadAvatarInEditor ]);
|
}, [ isVisible, isInitalized, needsReset, loadAvatarInEditor ]);
|
||||||
|
|
||||||
|
useEffect(() =>
|
||||||
|
{
|
||||||
|
if(isVisible) return;
|
||||||
|
|
||||||
|
return () =>
|
||||||
|
{
|
||||||
|
setNeedsReset(true);
|
||||||
|
}
|
||||||
|
}, [ isVisible ]);
|
||||||
|
|
||||||
if(!isVisible || !figureData) return null;
|
if(!isVisible || !figureData) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user