From 6d164224e9b64e85cb1ed570ef647c869bce1b2c Mon Sep 17 00:00:00 2001
From: Yarden Shoham <git@yardenshoham.com>
Date: Fri, 29 Mar 2024 20:17:21 +0300
Subject: [PATCH] Remove jQuery class from the notification count (#30172)

- Switched from jQuery class functions to plain JavaScript `classList`
- Tested the notification count and it works as before

---------

Signed-off-by: Yarden Shoham <git@yardenshoham.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Giteabot <teabot@gitea.io>
(cherry picked from commit 56ac5f18e8022242316d86c8f3091bce554faebb)
---
 web_src/js/features/notification.js | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/web_src/js/features/notification.js b/web_src/js/features/notification.js
index 0a7ffe7afa..b57df9ce6a 100644
--- a/web_src/js/features/notification.js
+++ b/web_src/js/features/notification.js
@@ -1,5 +1,6 @@
 import $ from 'jquery';
 import {GET} from '../modules/fetch.js';
+import {toggleElem} from '../utils/dom.js';
 
 const {appSubUrl, notificationSettings, assetVersionEncoded} = window.config;
 let notificationSequenceNumber = 0;
@@ -177,14 +178,11 @@ async function updateNotificationCount() {
 
     const data = await response.json();
 
-    const $notificationCount = $('.notification_count');
-    if (data.new === 0) {
-      $notificationCount.addClass('tw-hidden');
-    } else {
-      $notificationCount.removeClass('tw-hidden');
-    }
+    toggleElem('.notification_count', data.new !== 0);
 
-    $notificationCount.text(`${data.new}`);
+    for (const el of document.getElementsByClassName('notification_count')) {
+      el.textContent = `${data.new}`;
+    }
 
     return `${data.new}`;
   } catch (error) {