From 756849d6e105f585285d6cb69453352ff50283c4 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Mon, 15 Aug 2022 18:36:45 +0200 Subject: [PATCH] Applied code suggestions --- ts/WoltLabSuite/Core/Ui/User/ObjectWatch.ts | 10 ++++++---- .../files/js/WoltLabSuite/Core/Ui/User/ObjectWatch.js | 9 ++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ts/WoltLabSuite/Core/Ui/User/ObjectWatch.ts b/ts/WoltLabSuite/Core/Ui/User/ObjectWatch.ts index 8304a6d4b4..84fe8f77cf 100644 --- a/ts/WoltLabSuite/Core/Ui/User/ObjectWatch.ts +++ b/ts/WoltLabSuite/Core/Ui/User/ObjectWatch.ts @@ -32,11 +32,13 @@ async function click(element: HTMLElement): Promise { 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"); }); } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/ObjectWatch.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/ObjectWatch.js index c9beb674ab..3392e50330 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/ObjectWatch.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/ObjectWatch.js @@ -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 -- 2.20.1