From 7fab67fe67bec42d4b429f9cd6145c91289cd2a8 Mon Sep 17 00:00:00 2001 From: huutech <20178761+huult@users.noreply.github.com> Date: Thu, 4 Dec 2025 09:21:16 +0700 Subject: [PATCH] fix download icon hide large imgage --- src/components/Image/BaseImage.native.tsx | 5 ++++- src/components/Image/BaseImage.tsx | 10 +++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/Image/BaseImage.native.tsx b/src/components/Image/BaseImage.native.tsx index 669f89204988..77726e98f5bf 100644 --- a/src/components/Image/BaseImage.native.tsx +++ b/src/components/Image/BaseImage.native.tsx @@ -8,9 +8,12 @@ import type {BaseImageProps} from './types'; function BaseImage({onLoad, source, ...props}: BaseImageProps) { const isLoadedRef = useRef(false); const attachmentContext = useContext(AttachmentStateContext); - const {setAttachmentLoaded} = attachmentContext || {}; + const {setAttachmentLoaded, isAttachmentLoaded} = attachmentContext || {}; useEffect(() => { + if (isAttachmentLoaded?.(source as AttachmentSource)) { + return; + } setAttachmentLoaded(source as AttachmentSource, false); // eslint-disable-next-line react-compiler/react-compiler // eslint-disable-next-line react-hooks/exhaustive-deps diff --git a/src/components/Image/BaseImage.tsx b/src/components/Image/BaseImage.tsx index 46f587f44175..bc8cbed125cb 100644 --- a/src/components/Image/BaseImage.tsx +++ b/src/components/Image/BaseImage.tsx @@ -1,19 +1,23 @@ import React, {useCallback, useContext, useEffect} from 'react'; import {Image as RNImage} from 'react-native'; -import type {ImageLoadEventData, ImageSourcePropType} from 'react-native'; +import type {ImageLoadEvent, ImageSourcePropType} from 'react-native'; import type {AttachmentSource} from '@components/Attachments/types'; import {AttachmentStateContext} from '@pages/media/AttachmentModalScreen/AttachmentModalBaseContent/AttachmentStateContextProvider'; import type {BaseImageProps} from './types'; function BaseImage({onLoad, source, ...props}: BaseImageProps) { - const {setAttachmentLoaded} = useContext(AttachmentStateContext); + const {setAttachmentLoaded, isAttachmentLoaded} = useContext(AttachmentStateContext); useEffect(() => { + if (isAttachmentLoaded?.(source as AttachmentSource)) { + return; + } + setAttachmentLoaded?.(source as AttachmentSource, false); // eslint-disable-next-line react-compiler/react-compiler // eslint-disable-next-line react-hooks/exhaustive-deps }, []); const imageLoadedSuccessfully = useCallback( - (event: {nativeEvent: ImageLoadEventData}) => { + (event: ImageLoadEvent) => { setAttachmentLoaded?.(source as AttachmentSource, true); if (!onLoad) { return;