Skip to content

Commit 99d4ea3

Browse files
committed
Use elementsCall
1 parent 9f83631 commit 99d4ea3

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

web_src/js/features/notification.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import $ from 'jquery';
22
import {GET} from '../modules/fetch.js';
3-
import {toggleElem} from '../utils/dom.js';
3+
import {elementsCall, toggleElem} from '../utils/dom.js';
44

55
const {appSubUrl, notificationSettings, assetVersionEncoded} = window.config;
66
let notificationSequenceNumber = 0;
@@ -179,10 +179,7 @@ async function updateNotificationCount() {
179179
const data = await response.json();
180180

181181
toggleElem('.notification_count', data.new !== 0);
182-
183-
for (const el of document.getElementsByClassName('notification_count')) {
184-
el.textContent = `${data.new}`;
185-
}
182+
elementsCall('.notification_count', (el) => el.textContent = `${data.new}`);
186183

187184
return `${data.new}`;
188185
} catch (error) {

web_src/js/utils/dom.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {debounce} from 'throttle-debounce';
22

3-
function elementsCall(el, func, ...args) {
3+
export function elementsCall(el, func, ...args) {
44
if (typeof el === 'string' || el instanceof String) {
55
el = document.querySelectorAll(el);
66
}

0 commit comments

Comments
 (0)