From 5ea9b16e147012a6a0ef0449064a70d308631e21 Mon Sep 17 00:00:00 2001 From: pkong-ds Date: Tue, 27 Aug 2024 22:58:16 +0800 Subject: [PATCH] Move error checking & state update in generatePreviewWorker --- public/scripts/upload.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/public/scripts/upload.js b/public/scripts/upload.js index 83dc9f9..24add2e 100644 --- a/public/scripts/upload.js +++ b/public/scripts/upload.js @@ -251,6 +251,13 @@ class RootViewModel { } async generatePreviewMockup(imageUpload) { + if (newImage.isErrorState) { + return; + } + window.viewModel.fileList.updateImageUploadStateByULID( + newImage.ulid, + ImageUploadState.GeneratingPreview, + ); runPreviewWorker(await this.getPreviewWorker(), imageUpload); } @@ -785,14 +792,6 @@ function main() { return; } const newImage = viewModel.fileList.imageUploads[newLen - 1]; - - if (newImage.isErrorState) { - return; - } - window.viewModel.fileList.updateImageUploadStateByULID( - newImage.ulid, - ImageUploadState.GeneratingPreview, - ); viewModel.generatePreviewMockup(newImage); }, );