Commit dee10bfe authored by JC Brand's avatar JC Brand

Clear MUC disco after closing a room

This is to avoid having a stale/inaccurate MUC features list when
reopening a previously closed MUC
parent cd05b897
...@@ -304,6 +304,10 @@ ...@@ -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);
} }
......
...@@ -130,13 +130,12 @@ ...@@ -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 @@ ...@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment