bugfix: wait for notification menu to add listener

This commit is contained in:
Matthieu Fesselier 2020-04-07 15:09:54 +02:00
parent 8db3fb9471
commit 8c6daf097b

View File

@ -316,7 +316,11 @@ document.addEventListener("DOMContentLoaded", function(event) {
//- Fix badges performances
// on load time
document.getElementById('notifications-list').addEventListener('populate', (event) => {
const checkNotificationMenuExist = setInterval(function () { // wait for notification menu to exist
const notifsMenu = document.getElementById('notifications-list');
if (notifsMenu) {
clearInterval(checkNotificationMenuExist);
notifsMenu.addEventListener('populate', (event) => {
const checkExist = setInterval(function () { // wait for left menus to exist
const subMenus = document.querySelectorAll('.sub-menu > sib-display > div');
if (subMenus.length >= 2) {
@ -325,6 +329,8 @@ document.addEventListener("DOMContentLoaded", function(event) {
}
}, 500);
}, { once: true });
}
}, 500);
// on refresh notification list
window.addEventListener('notificationsRefresh', () => {