mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-20 07:26:19 +00:00
🆙 Small test 1
This commit is contained in:
@@ -21,11 +21,15 @@ export const LayoutAvatarImageView: FC<LayoutAvatarImageViewProps> = props =>
|
|||||||
const [ isReady, setIsReady ] = useState<boolean>(false);
|
const [ isReady, setIsReady ] = useState<boolean>(false);
|
||||||
const [ updateId, setUpdateId ] = useState<number>(0);
|
const [ updateId, setUpdateId ] = useState<number>(0);
|
||||||
const isDisposed = useRef(false);
|
const isDisposed = useRef(false);
|
||||||
const isPlaceholderRef = useRef(false);
|
const figureKeyRef = useRef<string>(null);
|
||||||
|
|
||||||
useNitroEvent(NitroEventType.AVATAR_ASSET_LOADED, () =>
|
useNitroEvent(NitroEventType.AVATAR_ASSET_LOADED, () =>
|
||||||
{
|
{
|
||||||
if(isPlaceholderRef.current) setUpdateId(prev => prev + 1);
|
if(figureKeyRef.current)
|
||||||
|
{
|
||||||
|
AVATAR_IMAGE_CACHE.delete(figureKeyRef.current);
|
||||||
|
setUpdateId(prev => prev + 1);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const getClassNames = useMemo(() =>
|
const getClassNames = useMemo(() =>
|
||||||
@@ -61,9 +65,10 @@ export const LayoutAvatarImageView: FC<LayoutAvatarImageViewProps> = props =>
|
|||||||
|
|
||||||
const figureKey = [ figure, gender, direction, headOnly ].join('-');
|
const figureKey = [ figure, gender, direction, headOnly ].join('-');
|
||||||
|
|
||||||
|
figureKeyRef.current = figureKey;
|
||||||
|
|
||||||
if(AVATAR_IMAGE_CACHE.has(figureKey))
|
if(AVATAR_IMAGE_CACHE.has(figureKey))
|
||||||
{
|
{
|
||||||
isPlaceholderRef.current = false;
|
|
||||||
setAvatarUrl(AVATAR_IMAGE_CACHE.get(figureKey));
|
setAvatarUrl(AVATAR_IMAGE_CACHE.get(figureKey));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -73,7 +78,7 @@ export const LayoutAvatarImageView: FC<LayoutAvatarImageViewProps> = props =>
|
|||||||
{
|
{
|
||||||
if(isDisposed.current) return;
|
if(isDisposed.current) return;
|
||||||
|
|
||||||
isPlaceholderRef.current = false;
|
AVATAR_IMAGE_CACHE.delete(figureKey);
|
||||||
setUpdateId(prev => prev + 1);
|
setUpdateId(prev => prev + 1);
|
||||||
},
|
},
|
||||||
dispose: null,
|
dispose: null,
|
||||||
@@ -90,15 +95,7 @@ export const LayoutAvatarImageView: FC<LayoutAvatarImageViewProps> = props =>
|
|||||||
|
|
||||||
if(imageUrl && !isDisposed.current)
|
if(imageUrl && !isDisposed.current)
|
||||||
{
|
{
|
||||||
if(!avatarImage.isPlaceholder())
|
if(!avatarImage.isPlaceholder()) AVATAR_IMAGE_CACHE.set(figureKey, imageUrl);
|
||||||
{
|
|
||||||
AVATAR_IMAGE_CACHE.set(figureKey, imageUrl);
|
|
||||||
isPlaceholderRef.current = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
isPlaceholderRef.current = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
setAvatarUrl(imageUrl);
|
setAvatarUrl(imageUrl);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,11 @@ export const AvatarEditorFigureSetItemView: FC<{
|
|||||||
|
|
||||||
useNitroEvent(NitroEventType.AVATAR_ASSET_LOADED, () =>
|
useNitroEvent(NitroEventType.AVATAR_ASSET_LOADED, () =>
|
||||||
{
|
{
|
||||||
if(!assetUrl || !assetUrl.length) setRetryId(prev => prev + 1);
|
if(!assetUrl || !assetUrl.length)
|
||||||
|
{
|
||||||
|
AvatarEditorThumbnailsHelper.clearCache();
|
||||||
|
setRetryId(prev => prev + 1);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() =>
|
useEffect(() =>
|
||||||
|
|||||||
Reference in New Issue
Block a user