From b81286ed0fdef2ff9f0f95cdd077fb37ed406173 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 3 Aug 2023 13:40:42 +0200 Subject: [PATCH] Prevent parallel executions of the store code installation See https://www.woltlab.com/community/thread/300905/ --- .../Core/Acp/Ui/Package/QuickInstallation.ts | 19 +++++-------------- .../Core/Acp/Ui/Package/QuickInstallation.js | 15 +++++---------- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/ts/WoltLabSuite/Core/Acp/Ui/Package/QuickInstallation.ts b/ts/WoltLabSuite/Core/Acp/Ui/Package/QuickInstallation.ts index 0580d742b4..f2fe2f15c1 100644 --- a/ts/WoltLabSuite/Core/Acp/Ui/Package/QuickInstallation.ts +++ b/ts/WoltLabSuite/Core/Acp/Ui/Package/QuickInstallation.ts @@ -35,6 +35,10 @@ type Response = function detectCode(): void { const value = codeInput.value.trim(); + if (value === "") { + innerError(codeInput, false); + return; + } let isValid = false; if (value.startsWith("WoltLab_StoreCode_Do_Not_Share_")) { @@ -136,20 +140,7 @@ export function setup(): void { void refreshPackageDatabase(); }); - codeInput.addEventListener("keydown", (event) => { - if (event.key === "Enter") { - event.preventDefault(); - - detectCode(); - } - }); - - codeInput.addEventListener("paste", (event) => { - event.preventDefault(); - - const value = event.clipboardData!.getData("text/plain"); - codeInput.value = value; - + codeInput.addEventListener("input", () => { detectCode(); }); } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Package/QuickInstallation.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Package/QuickInstallation.js index e522eea04b..821c1edd77 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Package/QuickInstallation.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Package/QuickInstallation.js @@ -17,6 +17,10 @@ define(["require", "exports", "tslib", "../../../Ajax", "../../../Ajax/Status", let codeInput; function detectCode() { const value = codeInput.value.trim(); + if (value === "") { + (0, Util_1.innerError)(codeInput, false); + return; + } let isValid = false; if (value.startsWith("WoltLab_StoreCode_Do_Not_Share_")) { const decodedValue = window.atob(value.replace(/^WoltLab_StoreCode_Do_Not_Share_/, "")); @@ -107,16 +111,7 @@ define(["require", "exports", "tslib", "../../../Ajax", "../../../Ajax/Status", // pasting the StoreCode into the input. void refreshPackageDatabase(); }); - codeInput.addEventListener("keydown", (event) => { - if (event.key === "Enter") { - event.preventDefault(); - detectCode(); - } - }); - codeInput.addEventListener("paste", (event) => { - event.preventDefault(); - const value = event.clipboardData.getData("text/plain"); - codeInput.value = value; + codeInput.addEventListener("input", () => { detectCode(); }); } -- 2.20.1