Skip to content

Commit

Permalink
Remove jQuery class from the notification count (#30172)
Browse files Browse the repository at this point in the history
- 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>
  • Loading branch information
3 people authored Mar 29, 2024
1 parent 9119934 commit 56ac5f1
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions web_src/js/features/notification.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 56ac5f1

Please sign in to comment.