Clear MUC disco after closing a room

This is to avoid having a stale/inaccurate MUC features list when
reopening a previously closed MUC
This commit is contained in:
JC Brand 2018-09-13 11:23:17 +02:00
parent cd05b89726
commit dee10bfe45
2 changed files with 37 additions and 36 deletions

View File

@ -304,6 +304,10 @@
*/
this.occupants.browserStorage._clear();
this.occupants.reset();
const disco_entity = _converse.disco_entities.get(this.get('jid'));
if (disco_entity) {
disco_entity.destroy();
}
if (_converse.connection.connected) {
this.sendUnavailablePresence(exit_msg);
}

View File

@ -130,13 +130,12 @@
return _converse.api.rooms.open(room_jid).then(() => {
view = _converse.chatboxviews.get(room_jid);
if (!_converse.disco_entities.get(room_jid)) {
utils.waitUntil(() => _.get(_.filter(
return utils.waitUntil(() => _.get(_.filter(
stanzas,
iq => iq.nodeTree.querySelector(
`iq[to="${room_jid}"] query[xmlns="http://jabber.org/protocol/disco#info"]`
)).pop(), 'nodeTree'))
.then(stanza => {
)).pop(), 'nodeTree'));
}).then(stanza => {
const features_stanza = $iq({
'from': room_jid,
'id': stanza.getAttribute('id'),
@ -164,8 +163,6 @@
.c('field', {'type':'text-single', 'var':'muc#roominfo_occupants', 'label':'Number of occupants'})
.c('value').t(0);
_converse.connection._dataRecv(utils.createRequest(features_stanza));
});
}
return utils.waitUntil(() => _.filter(
stanzas,
s => sizzle(`iq[to="${room_jid}"] query[node="x-roomuser-item"]`, s.nodeTree).length