From 295ae98916189c4920ab53903b94f4953fde68c9 Mon Sep 17 00:00:00 2001 From: Nam Le Date: Fri, 5 Jan 2024 22:12:59 +0700 Subject: [PATCH] fix set source and check local file --- src/components/AttachmentModal.js | 4 ++-- src/libs/ReceiptUtils.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/AttachmentModal.js b/src/components/AttachmentModal.js index d24d1e18907f..aa6c16798ccd 100755 --- a/src/components/AttachmentModal.js +++ b/src/components/AttachmentModal.js @@ -126,7 +126,7 @@ function AttachmentModal(props) { const [isAuthTokenRequired, setIsAuthTokenRequired] = useState(props.isAuthTokenRequired); const [attachmentInvalidReasonTitle, setAttachmentInvalidReasonTitle] = useState(''); const [attachmentInvalidReason, setAttachmentInvalidReason] = useState(null); - const [source, setSource] = useState(props.source); + const [source, setSource] = useState(() => props.source); const [modalType, setModalType] = useState(CONST.MODAL.MODAL_TYPE.CENTERED_UNSWIPEABLE); const [isConfirmButtonDisabled, setIsConfirmButtonDisabled] = useState(false); const [confirmButtonFadeAnimation] = useState(() => new Animated.Value(1)); @@ -359,7 +359,7 @@ function AttachmentModal(props) { }, []); useEffect(() => { - setSource(props.source); + setSource(() => props.source); }, [props.source]); useEffect(() => { diff --git a/src/libs/ReceiptUtils.ts b/src/libs/ReceiptUtils.ts index 1adb5957587b..d2fddf87670c 100644 --- a/src/libs/ReceiptUtils.ts +++ b/src/libs/ReceiptUtils.ts @@ -66,7 +66,7 @@ function getThumbnailAndImageURIs(transaction: Transaction, receiptPath: string image = ReceiptSVG; } - const isLocalFile = typeof path === 'number' || path.startsWith('blob:') || path.startsWith('file:'); + const isLocalFile = typeof path === 'number' || path.startsWith('blob:') || path.startsWith('file:') || path === ReceiptGeneric; return {thumbnail: image, image: path, isLocalFile}; }