Skip to content

Remove jQuery class from the notification count #30172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 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 {elementsCall, toggleElem} from '../utils/dom.js';

const {appSubUrl, notificationSettings, assetVersionEncoded} = window.config;
let notificationSequenceNumber = 0;
Expand Down Expand Up @@ -177,14 +178,8 @@ 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');
}

$notificationCount.text(`${data.new}`);
toggleElem('.notification_count', data.new !== 0);
elementsCall('.notification_count', (el) => el.textContent = `${data.new}`);

return `${data.new}`;
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion web_src/js/utils/dom.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {debounce} from 'throttle-debounce';

function elementsCall(el, func, ...args) {
export function elementsCall(el, func, ...args) {
if (typeof el === 'string' || el instanceof String) {
el = document.querySelectorAll(el);
}
Expand Down