Skip to content
Snippets Groups Projects
Verified Commit a1806b70 authored by Jean-Baptiste Pasquier's avatar Jean-Baptiste Pasquier
Browse files

update: read event on chatbox focus

parent 7bcf828e
No related branches found
No related tags found
No related merge requests found
Pipeline #4694 passed
...@@ -112,7 +112,8 @@ export const SibChat = { ...@@ -112,7 +112,8 @@ export const SibChat = {
jid = jid.toLowerCase(); jid = jid.toLowerCase();
this._converse.root = root; this._converse.root = root;
const converse_el = [...document.querySelectorAll('sib-chat')] // Get the current used sib-chat
const converse_el = Array.from(document.querySelectorAll('sib-chat'))
.map(el => el.shadowRoot.getElementById('conversejs')) .map(el => el.shadowRoot.getElementById('conversejs'))
.filter(el => el) .filter(el => el)
.pop(); .pop();
...@@ -140,7 +141,7 @@ export const SibChat = { ...@@ -140,7 +141,7 @@ export const SibChat = {
this._converse.api.chats.open(jid); this._converse.api.chats.open(jid);
} }
} }
}) });
// Initialize change change plugin // Initialize change change plugin
converse.plugins.add('conversejs-changechat', converse_sib.service.plugins.sibChat); converse.plugins.add('conversejs-changechat', converse_sib.service.plugins.sibChat);
...@@ -151,6 +152,24 @@ export const SibChat = { ...@@ -151,6 +152,24 @@ export const SibChat = {
} }
}); });
// Initialize deferred resolution plugin
converse.plugins.add('conversejs-sib-focused', {
initialize() {
this._converse.api.listen.on('chatBoxFocused', function() {
// Get the currently used sib-chat & send read event of
const resource = Array.from(document.querySelectorAll('sib-chat'))
.filter(el => {return el.shadowRoot.getElementById('conversejs')})
.pop()
._component.resource;
window.dispatchEvent(new CustomEvent('read', {
detail: {
resource: resource
}
}));
});
}
});
let user = await document.querySelector('sib-auth').getUser(); let user = await document.querySelector('sib-auth').getUser();
user = await store.get(user); user = await store.get(user);
...@@ -208,7 +227,7 @@ export const SibChat = { ...@@ -208,7 +227,7 @@ export const SibChat = {
fileupload: false, fileupload: false,
toggle_occupants: false toggle_occupants: false
}, },
'whitelisted_plugins': ['conversejs-sib-connected', 'conversejs-changechat'], 'whitelisted_plugins': ['conversejs-sib-connected', 'conversejs-sib-focused', 'conversejs-changechat'],
}); });
converse_sib.loaded_deferred.resolve(); converse_sib.loaded_deferred.resolve();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment