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;
|
2020-09-16 19:31:26 +00:00
|
|
|
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']}"]`);
|
2020-09-16 19:31:26 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|