🆙 Small test 1

This commit is contained in:
duckietm
2026-04-01 11:48:43 +02:00
parent 49e1ac6307
commit bfb56f0a4e
2 changed files with 15 additions and 14 deletions
+10 -13
View File
@@ -21,11 +21,15 @@ export const LayoutAvatarImageView: FC<LayoutAvatarImageViewProps> = props =>
const [ isReady, setIsReady ] = useState<boolean>(false);
const [ updateId, setUpdateId ] = useState<number>(0);
const isDisposed = useRef(false);
const isPlaceholderRef = useRef(false);
const figureKeyRef = useRef<string>(null);
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(() =>
@@ -61,9 +65,10 @@ export const LayoutAvatarImageView: FC<LayoutAvatarImageViewProps> = props =>
const figureKey = [ figure, gender, direction, headOnly ].join('-');
figureKeyRef.current = figureKey;
if(AVATAR_IMAGE_CACHE.has(figureKey))
{
isPlaceholderRef.current = false;
setAvatarUrl(AVATAR_IMAGE_CACHE.get(figureKey));
}
else
@@ -73,7 +78,7 @@ export const LayoutAvatarImageView: FC<LayoutAvatarImageViewProps> = props =>
{
if(isDisposed.current) return;
isPlaceholderRef.current = false;
AVATAR_IMAGE_CACHE.delete(figureKey);
setUpdateId(prev => prev + 1);
},
dispose: null,
@@ -90,15 +95,7 @@ export const LayoutAvatarImageView: FC<LayoutAvatarImageViewProps> = props =>
if(imageUrl && !isDisposed.current)
{
if(!avatarImage.isPlaceholder())
{
AVATAR_IMAGE_CACHE.set(figureKey, imageUrl);
isPlaceholderRef.current = false;
}
else
{
isPlaceholderRef.current = true;
}
if(!avatarImage.isPlaceholder()) AVATAR_IMAGE_CACHE.set(figureKey, imageUrl);
setAvatarUrl(imageUrl);
}
@@ -26,7 +26,11 @@ export const AvatarEditorFigureSetItemView: FC<{
useNitroEvent(NitroEventType.AVATAR_ASSET_LOADED, () =>
{
if(!assetUrl || !assetUrl.length) setRetryId(prev => prev + 1);
if(!assetUrl || !assetUrl.length)
{
AvatarEditorThumbnailsHelper.clearCache();
setRetryId(prev => prev + 1);
}
});
useEffect(() =>