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.browserStorage._clear();
this.occupants.reset(); this.occupants.reset();
const disco_entity = _converse.disco_entities.get(this.get('jid'));
if (disco_entity) {
disco_entity.destroy();
}
if (_converse.connection.connected) { if (_converse.connection.connected) {
this.sendUnavailablePresence(exit_msg); this.sendUnavailablePresence(exit_msg);
} }

View File

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