Fix error handling in Acp/Ui/Package/QuickInstallation.ts
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 14 Apr 2022 10:18:22 +0000 (12:18 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 14 Apr 2022 10:18:22 +0000 (12:18 +0200)
ts/WoltLabSuite/Core/Acp/Ui/Package/QuickInstallation.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Package/QuickInstallation.js

index a6f2abaf84bc74bf78cb4b3691ad1f1d9142bbee..1333ee5645e03c921973fb1342e66881982c4cb9 100644 (file)
@@ -25,13 +25,9 @@ type InstallationCode = {
 type Response =
   | {
       queueID: number;
-      returnValues?: never;
     }
   | {
-      queueID?: never;
-      returnValues: {
-        template: string;
-      };
+      template: string;
     };
 
 function detectCode(): void {
@@ -79,10 +75,10 @@ async function prepareInstallation(data: InstallationCode): Promise<void> {
     })
     .dispatch()) as Response;
 
-  if (response.queueID) {
+  if ('queueID' in response) {
     const installation = new window.WCF.ACP.Package.Installation(response.queueID, undefined, false);
     installation.prepareInstallation();
-  } else if (response.returnValues) {
+  } else if ('template' in response) {
     UiDialog.open(
       {
         _dialogSetup() {
@@ -95,8 +91,10 @@ async function prepareInstallation(data: InstallationCode): Promise<void> {
           };
         },
       },
-      response.returnValues.template,
+      response.template,
     );
+  } else {
+    throw new Error('Unreachable');
   }
 }
 
index 291e28913d7f14f59b7af80f5855119fac41221e..733e03ccff99d291d84e1810bfdd3d2a7713b6a1 100644 (file)
@@ -54,11 +54,11 @@ define(["require", "exports", "tslib", "../../../Ajax", "../../../Core", "../../
             },
         })
             .dispatch());
-        if (response.queueID) {
+        if ('queueID' in response) {
             const installation = new window.WCF.ACP.Package.Installation(response.queueID, undefined, false);
             installation.prepareInstallation();
         }
-        else if (response.returnValues) {
+        else if ('template' in response) {
             Dialog_1.default.open({
                 _dialogSetup() {
                     return {
@@ -69,7 +69,10 @@ define(["require", "exports", "tslib", "../../../Ajax", "../../../Core", "../../
                         source: null,
                     };
                 },
-            }, response.returnValues.template);
+            }, response.template);
+        }
+        else {
+            throw new Error('Unreachable');
         }
     }
     function setup() {