mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: #12044, only load notifications when opening dropdown
update code to use bs5 class "show"
This commit is contained in:
@@ -1,25 +1,24 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('forum/header/notifications', ['components'], function (components) {
|
define('forum/header/notifications', function () {
|
||||||
const notifications = {};
|
const notifications = {};
|
||||||
|
|
||||||
notifications.prepareDOM = function () {
|
notifications.prepareDOM = function () {
|
||||||
const notifContainer = components.get('notifications');
|
const notifTrigger = $('[component="notifications"] [data-bs-toggle="dropdown"]');
|
||||||
const notifTrigger = notifContainer.children('a');
|
if (!notifTrigger.length) {
|
||||||
const notifList = components.get('notifications/list');
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
notifTrigger.on('click', function (e) {
|
notifTrigger.on('show.bs.dropdown', (ev) => {
|
||||||
e.preventDefault();
|
requireAndCall('loadNotifications', $(ev.target).parent().find('[component="notifications/list"]'));
|
||||||
if (notifContainer.hasClass('open')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
requireAndCall('loadNotifications', notifList);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (notifTrigger.parents('.dropdown').hasClass('open')) {
|
notifTrigger.each((index, el) => {
|
||||||
requireAndCall('loadNotifications', notifList);
|
const dropdownEl = $(el).parent().find('.dropdown-menu');
|
||||||
}
|
if (dropdownEl.hasClass('show')) {
|
||||||
|
requireAndCall('loadNotifications', dropdownEl.find('[component="notifications/list"]'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
socket.removeListener('event:new_notification', onNewNotification);
|
socket.removeListener('event:new_notification', onNewNotification);
|
||||||
socket.on('event:new_notification', onNewNotification);
|
socket.on('event:new_notification', onNewNotification);
|
||||||
|
|||||||
Reference in New Issue
Block a user