muc: loosen isJoined criteria

Handle any `error` IQ result or timeout from a MUC ping as indication that we're no longer joined.
This commit is contained in:
JC Brand 2019-12-11 10:06:03 +01:00
parent 720087bef2
commit f3a1351a42

View File

@ -419,7 +419,7 @@ converse.plugins.add('converse-muc', {
* @returns { Boolean } Returns `true` if we're still joined, otherwise returns `false`.
*/
async restoreFromCache () {
if (this.session.get('connection_status') === converse.ROOMSTATUS.ENTERED && await this.isJoined()) {
if (this.session.get('connection_status') === converse.ROOMSTATUS.ENTERED && (await this.isJoined())) {
// We've restored the room from cache and we're still joined.
await new Promise(resolve => this.features.fetch({'success': resolve, 'error': resolve}));
await this.fetchOccupants();
@ -1602,10 +1602,13 @@ converse.plugins.add('converse-muc', {
try {
await _converse.api.sendIQ(ping);
} catch (e) {
const sel = `error not-acceptable[xmlns="${Strophe.NS.STANZAS}"]`;
if (isElement(e) && sizzle(sel, e).length) {
return false;
if (e === null) {
log.error(`Timeout error while checking whether we're joined to MUC: ${this.get('jid')}`);
} else {
log.error(`Apparently we're no longer connected to MUC: ${this.get('jid')}`);
log.error(e);
}
return false;
}
return true;
},