Skip to content

Commit

Permalink
Merge pull request Expensify#28640 from dukenv0307/fix/27824
Browse files Browse the repository at this point in the history
Fix receipt image is opened in transaction thread report
  • Loading branch information
aldo-expensify authored Oct 31, 2023
2 parents 0a27554 + d5b9258 commit 2231ed0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/components/Attachments/AttachmentCarousel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@ function AttachmentCarousel({report, reportActions, source, onNavigate, setDownl
const [attachments, setAttachments] = useState([]);
const [activeSource, setActiveSource] = useState(source);
const [shouldShowArrows, setShouldShowArrows, autoHideArrows, cancelAutoHideArrows] = useCarouselArrows();
const [isReceipt, setIsReceipt] = useState(false);

const compareImage = useCallback(
(attachment) => {
if (attachment.isReceipt) {
if (attachment.isReceipt && isReceipt) {
const action = ReportActionsUtils.getParentReportAction(report);
const transactionID = _.get(action, ['originalMessage', 'IOUTransactionID']);
return attachment.transactionID === transactionID;
}
return attachment.source === source;
},
[source, report],
[source, report, isReceipt],
);

useEffect(() => {
Expand Down Expand Up @@ -86,10 +87,12 @@ function AttachmentCarousel({report, reportActions, source, onNavigate, setDownl
// to get the index of the current page
const entry = _.first(viewableItems);
if (!entry) {
setIsReceipt(false);
setActiveSource(null);
return;
}

setIsReceipt(entry.item.isReceipt);
setPage(entry.index);
setActiveSource(entry.item.source);

Expand Down
6 changes: 4 additions & 2 deletions src/components/Attachments/AttachmentCarousel/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,18 @@ function AttachmentCarousel({report, reportActions, source, onNavigate, onClose,
const [activeSource, setActiveSource] = useState(source);
const [isPinchGestureRunning, setIsPinchGestureRunning] = useState(true);
const [shouldShowArrows, setShouldShowArrows, autoHideArrows, cancelAutoHideArrows] = useCarouselArrows();
const [isReceipt, setIsReceipt] = useState(false);

const compareImage = useCallback(
(attachment) => {
if (attachment.isReceipt) {
if (attachment.isReceipt && isReceipt) {
const action = ReportActionsUtils.getParentReportAction(report);
const transactionID = _.get(action, ['originalMessage', 'IOUTransactionID']);
return attachment.transactionID === transactionID;
}
return attachment.source === source;
},
[source, report],
[source, report, isReceipt],
);

useEffect(() => {
Expand Down Expand Up @@ -76,6 +77,7 @@ function AttachmentCarousel({report, reportActions, source, onNavigate, onClose,
const item = attachments[newPageIndex];

setPage(newPageIndex);
setIsReceipt(item.isReceipt);
setActiveSource(item.source);

onNavigate(item);
Expand Down

0 comments on commit 2231ed0

Please sign in to comment.