From bfb56f0a4ea597935ad26c6e66fd9293b863965f Mon Sep 17 00:00:00 2001 From: duckietm Date: Wed, 1 Apr 2026 11:48:43 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=86=99=20Small=20test=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/layout/LayoutAvatarImageView.tsx | 23 ++++++++----------- .../AvatarEditorFigureSetItemView.tsx | 6 ++++- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/common/layout/LayoutAvatarImageView.tsx b/src/common/layout/LayoutAvatarImageView.tsx index 89779bb..fdde1ac 100644 --- a/src/common/layout/LayoutAvatarImageView.tsx +++ b/src/common/layout/LayoutAvatarImageView.tsx @@ -21,11 +21,15 @@ export const LayoutAvatarImageView: FC = props => const [ isReady, setIsReady ] = useState(false); const [ updateId, setUpdateId ] = useState(0); const isDisposed = useRef(false); - const isPlaceholderRef = useRef(false); + const figureKeyRef = useRef(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 = 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 = 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 = 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); } diff --git a/src/components/avatar-editor/figure-set/AvatarEditorFigureSetItemView.tsx b/src/components/avatar-editor/figure-set/AvatarEditorFigureSetItemView.tsx index 588005e..7b5d65c 100644 --- a/src/components/avatar-editor/figure-set/AvatarEditorFigureSetItemView.tsx +++ b/src/components/avatar-editor/figure-set/AvatarEditorFigureSetItemView.tsx @@ -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(() =>