Skip to content

Commit

Permalink
Merge pull request #23988 from Expensify/beaman-returnWhenAttachmentGone
Browse files Browse the repository at this point in the history
[CP Staging] Return early when dismissing modal so we don't call `onNavigate` with no attachments
  • Loading branch information
cristipaval authored Aug 1, 2023
2 parents 6c9e459 + df03ef6 commit 73e097c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/components/AttachmentCarousel/createInitialState.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function createInitialState(props) {
const page = _.findIndex(attachments, (a) => a.source === props.source);
if (page === -1) {
Navigation.dismissModal();
return;
}

// Update the parent modal's state with the source and name from the mapped attachments
Expand Down
6 changes: 4 additions & 2 deletions src/components/AttachmentCarousel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ function AttachmentCarousel(props) {

useEffect(() => {
const initialState = createInitialState(props);
setPage(initialState.page);
setAttachments(initialState.attachments);
if (initialState) {
setPage(initialState.page);
setAttachments(initialState.attachments);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [props.reportActions]);

Expand Down

0 comments on commit 73e097c

Please sign in to comment.