Skip to content
Snippets Groups Projects
Commit 5e2666b2 authored by Emmanuel Vodor's avatar Emmanuel Vodor
Browse files

Merge branch 'new_rai_fixes' into 'beta'

Wait for RAI sub promise when connected

See merge request !123
parents cbad27ab afbaae04
No related branches found
Tags v5.2.0-beta.1
2 merge requests!123Wait for RAI sub promise when connected,!122Custom Emoji Drawer & Inline Message Actions
Pipeline #10551 passed
......@@ -108,7 +108,7 @@ converse.plugins.add('converse-rai', {
* @param {string|Array} jids
* @returns {void}
*/
subscribe(jids) {
async subscribe(jids) {
if (!api.settings.get('muc_subscribe_to_rai')) {
log.error(`You must enable the 'muc_subscribe_to_rai' option before subscribing to a MUC.`);
return;
......@@ -118,15 +118,16 @@ converse.plugins.add('converse-rai', {
jids = [jids];
}
const muc_domains = jids.map(jid => Strophe.getDomainFromJid(jid));
const muc_domains = _.uniq(jids.map(jid => Strophe.getDomainFromJid(jid)));
_.uniq(muc_domains).forEach(muc_domain => {
const rai = $pres({ to: muc_domain, id: u.getUniqueId() }).c('rai', {
for (let domain of muc_domains) {
const rai = $pres({ to: domain, id: u.getUniqueId() }).c('rai', {
'xmlns': Strophe.NS.RAI,
});
api.send(rai);
log.debug(`Sent RAI stanza for domain "${muc_domain}"`);
});
await _converse.connection.send(rai);
log.debug(`Sent RAI stanza for domain "${domain}"`);
}
},
});
......
......@@ -7,7 +7,8 @@ converse.plugins.add('sib-subscribe-to-rai', {
dependencies: [
'converse-rai',
],
async initialize() {
initialize() {
const { log } = converse.env;
const _converse = this._converse;
const { api } = _converse;
......@@ -51,14 +52,16 @@ converse.plugins.add('sib-subscribe-to-rai', {
}, 250);
});
// @MattJ Here userRooms is an array of each jabberID the user is on.
let userRooms = (await Promise.all([
getCircles,
getProjects,
])).flat();
api.listen.on('connected', async () => {
api.listen.on('connected', () => {
api.rooms.subscribe(userRooms);
// @MattJ Here userRooms is an array of each jabberID the user is on.
let userRooms = (await Promise.all([
getCircles,
getProjects,
])).flat();
log.info(`User rooms: ${userRooms.join(', ')}`);
await api.rooms.subscribe(userRooms);
});
api.listen.on('chatRoomHasActivity', jid => {
......
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