From 00962d663500e7d519c599eda116e6c5ae012c43 Mon Sep 17 00:00:00 2001 From: Janne Schyffert <89573122+Karlkorv@users.noreply.github.com> Date: Wed, 5 Mar 2025 11:43:26 +0100 Subject: [PATCH] Fix error banner not getting removed on correct upload (#3114) This line: https://github.com/Stirling-Tools/Stirling-PDF/blob/9a0dad8bd7f2ae4333dab78d6313c5d95c4ac9b8/src/main/resources/static/js/DecryptFiles.js#L50 Appears to not relinquish flow control correctly and leads to `this.removeErrorBanner()` not getting called. Since the program still functions correctly I simply ensured that `removeErrorBanner()` is called before the `await` call to ensure that it works. Uploading a functioning pdf will now successfully remove the error banner. As to why the await call isn't functioning correctly I'm not sure, but the download appears to be working as it only seems to skip the error banner part. Closes #2419 --- ## Checklist ### General - [x] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [x] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md) (if applicable) - [x] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md) (if applicable) - [x] I have performed a self-review of my own code - [x] My changes generate no new warnings ### Documentation - [x] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [x] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [x] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [x] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#6-testing) for more details. --- src/main/resources/static/js/DecryptFiles.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/resources/static/js/DecryptFiles.js b/src/main/resources/static/js/DecryptFiles.js index a06687b1d..16e2e7aee 100644 --- a/src/main/resources/static/js/DecryptFiles.js +++ b/src/main/resources/static/js/DecryptFiles.js @@ -47,9 +47,11 @@ export class DecryptFile { }); if (response.ok) { - const decryptedBlob = await response.blob(); this.removeErrorBanner(); - return new File([decryptedBlob], file.name, {type: 'application/pdf'}); + const decryptedBlob = await response.blob(); + return new File([decryptedBlob], file.name, { + type: "application/pdf", + }); } else { const errorText = await response.text(); console.error(`${window.decrypt.invalidPassword} ${errorText}`);