chore: avoid repeat rendering for clicking same image

This commit is contained in:
jialin
2025-04-18 15:13:51 +08:00
parent ed5afff5d7
commit 6270226ead
@@ -359,10 +359,14 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
handleUpdateImageList handleUpdateImageList
]); ]);
const handleOnImgClick = useCallback((item: any, isOrigin: boolean) => { const handleOnImgClick = useCallback(
(item: any, isOrigin: boolean) => {
if (item.progress < 100 && !isOrigin) { if (item.progress < 100 && !isOrigin) {
return; return;
} }
if (item.uid === activeImgUid) {
return;
}
setActiveImgUid(item.uid); setActiveImgUid(item.uid);
setImage(item.dataUrl); setImage(item.dataUrl);
setImageStatus({ setImageStatus({
@@ -371,7 +375,9 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
width: item.width, width: item.width,
height: item.height height: item.height
}); });
}, []); },
[activeImgUid]
);
useEffect(() => { useEffect(() => {
if (imageList.length > 0) { if (imageList.length > 0) {