Prevent parallel executions of the store code installation
authorAlexander Ebert <ebert@woltlab.com>
Thu, 3 Aug 2023 11:40:42 +0000 (13:40 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 3 Aug 2023 11:40:42 +0000 (13:40 +0200)
See https://www.woltlab.com/community/thread/300905/

ts/WoltLabSuite/Core/Acp/Ui/Package/QuickInstallation.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Package/QuickInstallation.js

index 0580d742b484af011e4b1198337f0d3f793ffe3b..f2fe2f15c12588ac64421532f04c485087143b28 100644 (file)
@@ -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();
   });
 }
index e522eea04b4b477b0dc54351a2147a1afccfd561..821c1edd775ef34c538052a090adda7db888c808 100644 (file)
@@ -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();
         });
     }