Merge branch 'bugfix/446-fix-badges-workaround' into 'master'

bugfix: wait for notification menu to add listener

See merge request applications/sib-app!127
This commit is contained in:
Jean-Baptiste Pasquier 2020-04-07 17:49:49 +00:00
commit d2c8226048
1 changed files with 15 additions and 9 deletions

View File

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