From 6d0f75d5ef93539f906a71d6f80a90efe8842037 Mon Sep 17 00:00:00 2001 From: Jack Nam <30609178+thienlnam@users.noreply.github.com> Date: Mon, 8 Jan 2024 13:12:29 +0800 Subject: [PATCH] Merge pull request #34030 from namhihi237/fix-crash-attachment fix crash attachment (cherry picked from commit cfdd159f3ae3be1c24bd9ada7fa1af7cfff6a549) --- 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..bcba68a3a0bd 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.startsWith('/'); return {thumbnail: image, image: path, isLocalFile}; }