Applied code suggestions
authorMarcel Werk <burntime@woltlab.com>
Mon, 15 Aug 2022 16:36:45 +0000 (18:36 +0200)
committerMarcel Werk <burntime@woltlab.com>
Mon, 15 Aug 2022 16:36:45 +0000 (18:36 +0200)
ts/WoltLabSuite/Core/Ui/User/ObjectWatch.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/ObjectWatch.js

index 8304a6d4b4d6576e1c5a324de945a82ec34b799e..84fe8f77cfc04f9806994ef46c0718549f347626 100644 (file)
@@ -32,11 +32,13 @@ async function click(element: HTMLElement): Promise<void> {
 
   if (dropdowns.has(objectID)) {
     dropdowns.get(objectID)!.forEach((element) => {
-      element.querySelectorAll(".userObjectWatchSelect").forEach((li) => {
-        li.classList.remove("active");
+      element.querySelectorAll(".userObjectWatchSelect").forEach((li: HTMLElement) => {
+        if (parseInt(li.dataset.subscribe!, 10) === subscribe) {
+          li.classList.add("active");
+        } else {
+          li.classList.remove("active");
+        }
       });
-
-      element.querySelector(`.userObjectWatchSelect[data-subscribe="${subscribe}"]`)?.classList.add("active");
     });
   }
 
index c9beb674ab67ff5d4d4d008f31337cf49de00a7c..3392e5033051c1d4531ca135ce9093063a85846d 100644 (file)
@@ -31,11 +31,14 @@ define(["require", "exports", "tslib", "../../Ajax", "../Notification", "../../L
             .dispatch();
         if (dropdowns.has(objectID)) {
             dropdowns.get(objectID).forEach((element) => {
-                var _a;
                 element.querySelectorAll(".userObjectWatchSelect").forEach((li) => {
-                    li.classList.remove("active");
+                    if (parseInt(li.dataset.subscribe, 10) === subscribe) {
+                        li.classList.add("active");
+                    }
+                    else {
+                        li.classList.remove("active");
+                    }
                 });
-                (_a = element.querySelector(`.userObjectWatchSelect[data-subscribe="${subscribe}"]`)) === null || _a === void 0 ? void 0 : _a.classList.add("active");
             });
         }
         document