Skip to content

[MOL-21511] Track images by id instead of index in image-upload - #765

Open
tientranngoc-alt wants to merge 2 commits into
pre-release/v2from
MOL-21511
Open

tientranngoc-alt wants to merge 2 commits into
pre-release/v2from
MOL-21511

Conversation

@tientranngoc-alt

Copy link
Copy Markdown

Type of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing apis or functionality to change)
  • Documentation (change to documentation, comments or API descriptions)
  • Tests (improvements to unit tests or E2E tests)
  • Other (technical improvements, refactoring, or changes that don't fall into the above categories)

Description of changes

  • Link to MOL-21511

  • Description of changes:

    • Problem: image-upload tracked images by array index. Async steps (compression, file-type check, drawing save) captured the index up front, so if the list changed mid-flight (image removed, added, or rejected), results were written to the wrong image, which makes the processing image frozen / causes something went wrong
    • Solution: Track images by id by adding updateImageById helper and used it for all status updates and removals, replacing updatedImages[index]

Checklist

  • Changes follow the project guidelines in CONTRIBUTING.md
  • Looks good on mobile and tablet
  • [] Updated documentation
  • [] Added/updated unit tests

...image,
...(i === activeFileIndex ? { status: EImageStatus.TO_DELETE } : {}),
}))
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switch to use id as well

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now that we are tracking by id, we need to ensure the prefilled images have unique / no missing ids. use generateRandomId() if they are not unique

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have tests to guard the issue mentioned? this can happen to upload and image processing in the main upload component and the image review

@weili-govtech weili-govtech added the type: bug Something isn't working label Oct 14, 2026
@weili-govtech weili-govtech added this to the v2-next milestone Oct 14, 2026
@tientranngoc-alt

Copy link
Copy Markdown
Author

resolved comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants