Commit e053b970 authored by JC Brand's avatar JC Brand

Set room `connection_status' to DISCONNECTED...

when receiving an `unavailable` presence for ourselves.
parent 85c4d144
......@@ -2138,6 +2138,7 @@
const __ = _converse.__;
await test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'oldnick');
const view = _converse.chatboxviews.get('lounge@localhost');
expect(view.model.get('connection_status')).toBe(converse.ROOMSTATUS.ENTERED);
const chat_content = view.el.querySelector('.chat-content');
let occupants = view.el.querySelector('.occupant-list');
......@@ -2169,6 +2170,7 @@
expect(sizzle('div.chat-info:last').pop().textContent).toBe(
__(_converse.muc.new_nickname_messages["303"], "newnick")
);
expect(view.model.get('connection_status')).toBe(converse.ROOMSTATUS.DISCONNECTED);
occupants = view.el.querySelector('.occupant-list');
expect(occupants.childNodes.length).toBe(1);
......@@ -2187,6 +2189,7 @@
.c('status').attrs({code:'110'}).nodeTree;
_converse.connection._dataRecv(test_utils.createRequest(presence));
expect(view.model.get('connection_status')).toBe(converse.ROOMSTATUS.ENTERED);
// XXX: currently we still have an additional "has entered the groupchat"
// notification for the new nickname. Ideally we'd not have
// that, but that's probably not possible without some
......
......@@ -1281,14 +1281,7 @@ converse.plugins.add('converse-muc', {
_converse.api.trigger('message', {'stanza': original_stanza, 'chatbox': this});
},
/**
* Handles all MUC presence stanzas.
* @private
* @method _converse.ChatRoom#onPresence
* @param { XMLElement } pres - The stanza
*/
onPresence (pres) {
if (pres.getAttribute('type') === 'error') {
onErrorPresence (pres) {
// TODO: currently showErrorMessageFromPresence handles
// 'error" presences in converse-muc-views.
// Instead, they should be handled here and the presence
......@@ -1298,13 +1291,23 @@ converse.plugins.add('converse-muc', {
} else {
this.save('connection_status', converse.ROOMSTATUS.DISCONNECTED);
}
return;
},
/**
* Handles all MUC presence stanzas.
* @private
* @method _converse.ChatRoom#onPresence
* @param { XMLElement } stanza
*/
onPresence (stanza) {
if (stanza.getAttribute('type') === 'error') {
return this.onErrorPresence(stanza);
}
const is_self = pres.querySelector("status[code='110']");
if (is_self && pres.getAttribute('type') !== 'unavailable') {
this.onOwnPresence(pres);
if (stanza.querySelector("status[code='110']")) {
this.onOwnPresence(stanza);
}
this.updateOccupantsOnPresence(pres);
this.updateOccupantsOnPresence(stanza);
if (this.get('role') !== 'none' && this.get('connection_status') === converse.ROOMSTATUS.CONNECTING) {
this.save('connection_status', converse.ROOMSTATUS.CONNECTED);
}
......@@ -1325,10 +1328,13 @@ converse.plugins.add('converse-muc', {
* @method _converse.ChatRoom#onOwnPresence
* @param { XMLElement } pres - The stanza
*/
onOwnPresence (pres) {
this.saveAffiliationAndRole(pres);
onOwnPresence (stanza) {
this.saveAffiliationAndRole(stanza);
const locked_room = pres.querySelector("status[code='201']");
if (stanza.getAttribute('type') === 'unavailable') {
this.save('connection_status', converse.ROOMSTATUS.DISCONNECTED);
} else {
const locked_room = stanza.querySelector("status[code='201']");
if (locked_room) {
if (this.get('auto_configure')) {
this.autoConfigureChatRoom().then(() => this.refreshRoomFeatures());
......@@ -1360,6 +1366,7 @@ converse.plugins.add('converse-muc', {
}
}
this.save('connection_status', converse.ROOMSTATUS.ENTERED);
}
},
/**
......
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