hubl/src/scripts/unreads-menu.js

20 lines
796 B
JavaScript
Raw Normal View History

2020-08-24 12:50:22 +00:00
document.addEventListener("DOMContentLoaded", function () {
2020-05-08 13:27:44 +00:00
window.addEventListener('newMessage', event => {
let jid = event.detail.jid;
Array.from(document.querySelectorAll('[data-jabberID="' + jid + '"]')).forEach(el => {
2020-05-08 13:27:44 +00:00
el.parentElement.parentElement.classList.add('unread');
});
});
window.addEventListener('read', (event) => {
if (event.detail && event.detail.resource && event.detail.resource['@id']) {
2020-08-05 13:43:05 +00:00
const badge = document.querySelector(`solid-badge[data-src="${event.detail.resource['@id']}"]`);
if (badge) {
badge.parentElement.parentElement.classList.remove('unread');
const project = badge.parentElement.parentElement.querySelector('.unread');
if (project) project.classList.remove('unread');
}
2020-05-08 13:27:44 +00:00
}
});
});