Skip to content

Commit

Permalink
Refine comment, add why point
Browse files Browse the repository at this point in the history
  • Loading branch information
wildan-m committed Oct 3, 2024
1 parent f104033 commit 33cd212
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@ function AttachmentCarousel({report, source, onNavigate, setDownloadButtonVisibi
let newIndex = newAttachments.findIndex(compareImage);
const index = attachments.findIndex(compareImage);

// If no matching attachment with the same index, dismiss the modal
// If newAttachments includes an attachment with the same index, update newIndex to that index.
// Previously, uploading an attachment offline would dismiss the modal when the image was previewed and the connection was restored.
// Now, instead of dismissing the modal, we replace it with the new attachment that has the same index.
if (newIndex === -1 && index !== -1 && newAttachments.at(index)) {
newIndex = index;
}

// If no matching attachment with the same index, dismiss the modal
if (newIndex === -1 && index !== -1 && attachments.at(index)) {
Navigation.dismissModal();
} else {
Expand Down
5 changes: 4 additions & 1 deletion src/components/Attachments/AttachmentCarousel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,14 @@ function AttachmentCarousel({report, source, onNavigate, setDownloadButtonVisibi
let newIndex = newAttachments.findIndex(compareImage);
const index = attachments.findIndex(compareImage);

// If no matching attachment with the same index, dismiss the modal
// If newAttachments includes an attachment with the same index, update newIndex to that index.
// Previously, uploading an attachment offline would dismiss the modal when the image was previewed and the connection was restored.
// Now, instead of dismissing the modal, we replace it with the new attachment that has the same index.
if (newIndex === -1 && index !== -1 && newAttachments.at(index)) {
newIndex = index;
}

// If no matching attachment with the same index, dismiss the modal
if (newIndex === -1 && index !== -1 && attachments.at(index)) {
Navigation.dismissModal();
} else {
Expand Down

0 comments on commit 33cd212

Please sign in to comment.