Skip to content

Commit

Permalink
Fix preview called when remove item
Browse files Browse the repository at this point in the history
  • Loading branch information
pkong-ds committed Aug 27, 2024
1 parent 8b48c6d commit 695da96
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions public/scripts/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -723,11 +723,15 @@ function main() {
},
);

// observe fileListViewModel: imageUploads[].length
// observe fileListViewModel: imageUploads[].length increase
// side effect: generate preview mockup
mobx.reaction(
() => viewModel.fileList.imageUploads.length,
(newLen) => {
(newLen, oldLen) => {
// we only want to trigger preview when the length increase
if (newLen <= oldLen) {
return;
}
if (viewModel.fileList.imageUploads.length !== newLen) {
console.error("unexpected mobx error, image upload length not matched");
return;
Expand Down

0 comments on commit 695da96

Please sign in to comment.