Commit a4567ee0 authored by JC Brand's avatar JC Brand

muc: Store `connection_status` in session storage

Otherwise we might run into a situation where a very old,
cached MUC that's being restored has `connection_status` set to ENTERED
(and the user happens to be in the MUC via another client)
and then restores cached messages without taking
`clear_messages_on_reconnection` into account.
parent 09b085be
......@@ -91,6 +91,7 @@
while (sent_IQs.length) { sent_IQs.pop(); }
await u.waitUntil(() => _converse.chatboxes.length === 1);
await test_utils.openAndEnterChatRoom(_converse, muc_jid, 'romeo');
view = _converse.chatboxviews.get(muc_jid);
await u.waitUntil(() => view.model.messages.length);
......
......@@ -292,13 +292,13 @@
spyOn(view.model, 'join').and.callThrough();
await test_utils.waitForReservedNick(_converse, muc_jid, '');
const input = await u.waitUntil(() => view.el.querySelector('input[name="nick"]'), 1000);
expect(view.model.get('connection_status')).toBe(converse.ROOMSTATUS.NICKNAME_REQUIRED);
expect(view.model.session.get('connection_status')).toBe(converse.ROOMSTATUS.NICKNAME_REQUIRED);
input.value = 'nicky';
view.el.querySelector('input[type=submit]').click();
expect(view.model.join).toHaveBeenCalled();
_converse.connection.IQ_stanzas = [];
await test_utils.getRoomFeatures(_converse, muc_jid);
await u.waitUntil(() => view.model.get('connection_status') === converse.ROOMSTATUS.CONNECTING);
await u.waitUntil(() => view.model.session.get('connection_status') === converse.ROOMSTATUS.CONNECTING);
// The user has just entered the room (because join was called)
// and receives their own presence from the server.
......@@ -327,7 +327,7 @@
.c('status').attrs({code:'201'}).nodeTree;
_converse.connection._dataRecv(test_utils.createRequest(presence));
await u.waitUntil(() => view.model.get('connection_status') === converse.ROOMSTATUS.ENTERED);
await u.waitUntil(() => view.model.session.get('connection_status') === converse.ROOMSTATUS.ENTERED);
await test_utils.returnMemberLists(_converse, muc_jid);
// await u.waitUntil(() => view.el.querySelectorAll('.chat-content .chat-info').length === 2);
......@@ -419,7 +419,7 @@
await test_utils.waitForReservedNick(_converse, muc_jid, nick);
test_utils.receiveOwnMUCPresence(_converse, muc_jid, nick);
const view = _converse.chatboxviews.get(muc_jid);
await u.waitUntil(() => (view.model.get('connection_status') === converse.ROOMSTATUS.ENTERED));
await u.waitUntil(() => (view.model.session.get('connection_status') === converse.ROOMSTATUS.ENTERED));
// Check in reverse order that we requested all three lists
const owner_iq = sent_IQs.pop();
......@@ -2203,7 +2203,7 @@
const muc_jid = 'coven@chat.shakespeare.lit';
await test_utils.openAndEnterChatRoom(_converse, muc_jid, 'romeo');
const view = _converse.chatboxviews.get(muc_jid);
expect(view.model.get('connection_status')).toBe(converse.ROOMSTATUS.ENTERED);
expect(view.model.session.get('connection_status')).toBe(converse.ROOMSTATUS.ENTERED);
await test_utils.sendMessage(view, 'hello world');
const stanza = u.toStanza(`
......@@ -2258,7 +2258,7 @@
const muc_jid = 'coven@chat.shakespeare.lit';
await test_utils.openAndEnterChatRoom(_converse, 'coven@chat.shakespeare.lit', 'romeo');
const view = _converse.chatboxviews.get(muc_jid);
expect(view.model.get('connection_status')).toBe(converse.ROOMSTATUS.ENTERED);
expect(view.model.session.get('connection_status')).toBe(converse.ROOMSTATUS.ENTERED);
const stanza = u.toStanza(`
<message from='${muc_jid}'
......@@ -2321,7 +2321,7 @@
const __ = _converse.__;
await test_utils.openAndEnterChatRoom(_converse, 'lounge@montague.lit', 'oldnick');
const view = _converse.chatboxviews.get('lounge@montague.lit');
expect(view.model.get('connection_status')).toBe(converse.ROOMSTATUS.ENTERED);
expect(view.model.session.get('connection_status')).toBe(converse.ROOMSTATUS.ENTERED);
const chat_content = view.el.querySelector('.chat-content');
await u.waitUntil(() => view.el.querySelectorAll('li .occupant-nick').length, 500);
......@@ -2355,7 +2355,7 @@
expect(sizzle('div.chat-info:last').pop().textContent.trim()).toBe(
__(_converse.muc.new_nickname_messages["303"], "newnick")
);
expect(view.model.get('connection_status')).toBe(converse.ROOMSTATUS.ENTERED);
expect(view.model.session.get('connection_status')).toBe(converse.ROOMSTATUS.ENTERED);
occupants = view.el.querySelector('.occupant-list');
expect(occupants.childNodes.length).toBe(1);
......@@ -2374,7 +2374,7 @@
.c('status').attrs({code:'110'}).nodeTree;
_converse.connection._dataRecv(test_utils.createRequest(presence));
expect(view.model.get('connection_status')).toBe(converse.ROOMSTATUS.ENTERED);
expect(view.model.session.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
......@@ -2450,7 +2450,7 @@
.c('feature', {'var': 'muc_nonanonymous'});
_converse.connection._dataRecv(test_utils.createRequest(features_stanza));
let view = _converse.chatboxviews.get('coven@chat.shakespeare.lit');
await u.waitUntil(() => (view.model.get('connection_status') === converse.ROOMSTATUS.CONNECTING));
await u.waitUntil(() => (view.model.session.get('connection_status') === converse.ROOMSTATUS.CONNECTING));
view = _converse.chatboxviews.get('coven@chat.shakespeare.lit');
expect(view.model.features.get('fetched')).toBeTruthy();
expect(view.model.features.get('passwordprotected')).toBe(true);
......@@ -3898,7 +3898,7 @@
spyOn(_converse.api, "trigger").and.callThrough();
expect(_converse.chatboxes.length).toBe(2);
_converse.connection._dataRecv(test_utils.createRequest(result_stanza));
await u.waitUntil(() => (view.model.get('connection_status') === converse.ROOMSTATUS.DISCONNECTED));
await u.waitUntil(() => (view.model.session.get('connection_status') === converse.ROOMSTATUS.DISCONNECTED));
await u.waitUntil(() => _converse.chatboxes.length === 1);
expect(_converse.api.trigger).toHaveBeenCalledWith('chatBoxClosed', jasmine.any(Object));
done();
......@@ -3986,7 +3986,7 @@
.c('feature', {'var': 'muc_temporary'}).up()
.c('feature', {'var': 'muc_membersonly'}).up();
_converse.connection._dataRecv(test_utils.createRequest(features_stanza));
await u.waitUntil(() => view.model.get('connection_status') === converse.ROOMSTATUS.CONNECTING);
await u.waitUntil(() => view.model.session.get('connection_status') === converse.ROOMSTATUS.CONNECTING);
const presence = $pres().attrs({
from: `${muc_jid}/romeo`,
......@@ -4031,7 +4031,7 @@
_converse.connection._dataRecv(test_utils.createRequest(features_stanza));
const view = _converse.chatboxviews.get(muc_jid);
await u.waitUntil(() => view.model.get('connection_status') === converse.ROOMSTATUS.CONNECTING);
await u.waitUntil(() => view.model.session.get('connection_status') === converse.ROOMSTATUS.CONNECTING);
const presence = $pres().attrs({
from: `${muc_jid}/romeo`,
......@@ -4163,7 +4163,7 @@
_converse.connection._dataRecv(test_utils.createRequest(features_stanza));
const view = _converse.chatboxviews.get(muc_jid);
await u.waitUntil(() => (view.model.get('connection_status') === converse.ROOMSTATUS.CONNECTING));
await u.waitUntil(() => (view.model.session.get('connection_status') === converse.ROOMSTATUS.CONNECTING));
const presence = $pres().attrs({
from: `${muc_jid}/romeo`,
......@@ -4204,7 +4204,7 @@
_converse.connection._dataRecv(test_utils.createRequest(features_stanza));
const view = _converse.chatboxviews.get(muc_jid);
await u.waitUntil(() => (view.model.get('connection_status') === converse.ROOMSTATUS.CONNECTING));
await u.waitUntil(() => (view.model.session.get('connection_status') === converse.ROOMSTATUS.CONNECTING));
const presence = $pres().attrs({
from: `${muc_jid}/romeo`,
......@@ -4246,7 +4246,7 @@
_converse.connection._dataRecv(test_utils.createRequest(features_stanza));
const view = _converse.chatboxviews.get(muc_jid);
await u.waitUntil(() => (view.model.get('connection_status') === converse.ROOMSTATUS.CONNECTING));
await u.waitUntil(() => (view.model.session.get('connection_status') === converse.ROOMSTATUS.CONNECTING));
const presence = $pres().attrs({
from: `${muc_jid}/romeo`,
......@@ -4288,7 +4288,7 @@
_converse.connection._dataRecv(test_utils.createRequest(features_stanza));
const view = _converse.chatboxviews.get(muc_jid);
await u.waitUntil(() => (view.model.get('connection_status') === converse.ROOMSTATUS.CONNECTING));
await u.waitUntil(() => (view.model.session.get('connection_status') === converse.ROOMSTATUS.CONNECTING));
const presence = $pres().attrs({
from: `${muc_jid}/romeo`,
......@@ -4347,7 +4347,7 @@
.c('feature', {'var': 'muc_temporary'}).up()
.c('feature', {'var': 'muc_membersonly'}).up();
_converse.connection._dataRecv(test_utils.createRequest(features_stanza));
await u.waitUntil(() => (view.model.get('connection_status') === converse.ROOMSTATUS.CONNECTING));
await u.waitUntil(() => (view.model.session.get('connection_status') === converse.ROOMSTATUS.CONNECTING));
expect(view.model.features.get('membersonly')).toBeTruthy();
await room_creation_promise;
......
......@@ -181,7 +181,7 @@
.c('field', {'type':'text-single', 'var':'muc#roominfo_occupants', 'label':'Number of occupants'})
.c('value').t(0);
_converse.connection._dataRecv(test_utils.createRequest(features_stanza));
await u.waitUntil(() => view.model.get('connection_status') === converse.ROOMSTATUS.CONNECTING)
await u.waitUntil(() => view.model.session.get('connection_status') === converse.ROOMSTATUS.CONNECTING)
let presence = $pres({
to: _converse.connection.jid,
from: 'coven@chat.shakespeare.lit/some1',
......
......@@ -664,7 +664,7 @@ converse.plugins.add('converse-muc-views', {
});
this.listenTo(this.model, 'change', this.renderHeading);
this.listenTo(this.model, 'change:connection_status', this.onConnectionStatusChanged);
this.listenTo(this.model.session, 'change:connection_status', this.onConnectionStatusChanged);
this.listenTo(this.model, 'change:hidden_occupants', this.updateOccupantsToggle);
this.listenTo(this.model, 'change:subject', this.setChatRoomSubject);
this.listenTo(this.model, 'configurationNeeded', this.getAndRenderConfigurationForm);
......@@ -704,7 +704,7 @@ converse.plugins.add('converse-muc-views', {
this.renderChatArea();
this.renderBottomPanel();
if (!_converse.muc_show_logs_before_join) {
this.model.get('connection_status') !== converse.ROOMSTATUS.ENTERED && this.showSpinner();
this.model.session.get('connection_status') !== converse.ROOMSTATUS.ENTERED && this.showSpinner();
}
if (!this.model.get('hidden')) {
this.show();
......@@ -723,7 +723,7 @@ converse.plugins.add('converse-muc-views', {
renderBottomPanel () {
const container = this.el.querySelector('.bottom-panel');
const entered = this.model.get('connection_status') === converse.ROOMSTATUS.ENTERED;
const entered = this.model.session.get('connection_status') === converse.ROOMSTATUS.ENTERED;
const can_edit = entered && !(this.model.features.get('moderated') && this.model.getOwnRole() === 'visitor');
container.innerHTML = tpl_chatroom_bottom_panel({__, can_edit, entered});
if (entered && can_edit) {
......@@ -1127,7 +1127,7 @@ converse.plugins.add('converse-muc-views', {
},
onConnectionStatusChanged () {
const conn_status = this.model.get('connection_status');
const conn_status = this.model.session.get('connection_status');
if (conn_status === converse.ROOMSTATUS.NICKNAME_REQUIRED) {
this.renderNicknameForm();
} else if (conn_status === converse.ROOMSTATUS.PASSWORD_REQUIRED) {
......@@ -1562,7 +1562,7 @@ converse.plugins.add('converse-muc-views', {
const container = this.el.querySelector('.chatroom-body');
container.insertAdjacentHTML('beforeend', html);
}
u.safeSave(this.model, {'connection_status': converse.ROOMSTATUS.NICKNAME_REQUIRED});
u.safeSave(this.model.session, {'connection_status': converse.ROOMSTATUS.NICKNAME_REQUIRED});
},
closeForm () {
......@@ -1623,7 +1623,7 @@ converse.plugins.add('converse-muc-views', {
this.password_form.model.set('validation_message', message);
}
u.showElement(this.password_form.el);
this.model.save('connection_status', converse.ROOMSTATUS.PASSWORD_REQUIRED);
this.model.session.save('connection_status', converse.ROOMSTATUS.PASSWORD_REQUIRED);
},
showDestroyedMessage () {
......@@ -1734,7 +1734,7 @@ converse.plugins.add('converse-muc-views', {
},
onOccupantRemoved (occupant) {
if (this.model.get('connection_status') === converse.ROOMSTATUS.ENTERED &&
if (this.model.session.get('connection_status') === converse.ROOMSTATUS.ENTERED &&
occupant.get('show') === 'online') {
this.showLeaveNotification(occupant);
}
......@@ -1784,7 +1784,7 @@ converse.plugins.add('converse-muc-views', {
showJoinNotification (occupant) {
if (!_converse.muc_show_join_leave ||
this.model.get('connection_status') !== converse.ROOMSTATUS.ENTERED) {
this.model.session.get('connection_status') !== converse.ROOMSTATUS.ENTERED) {
return;
}
const nick = occupant.get('nick'),
......@@ -1899,11 +1899,12 @@ converse.plugins.add('converse-muc-views', {
* @method _converse.ChatRoomView#renderAfterTransition
*/
renderAfterTransition () {
if (this.model.get('connection_status') == converse.ROOMSTATUS.NICKNAME_REQUIRED) {
const conn_status = this.model.session.get('connection_status')
if (conn_status == converse.ROOMSTATUS.NICKNAME_REQUIRED) {
this.renderNicknameForm();
} else if (this.model.get('connection_status') == converse.ROOMSTATUS.PASSWORD_REQUIRED) {
} else if (conn_status == converse.ROOMSTATUS.PASSWORD_REQUIRED) {
this.renderPasswordForm();
} else if (this.model.get('connection_status') == converse.ROOMSTATUS.ENTERED) {
} else if (conn_status == converse.ROOMSTATUS.ENTERED) {
this.hideChatRoomContents();
u.showElement(this.el.querySelector('.chat-area'));
u.showElement(this.el.querySelector('.occupants'));
......
......@@ -224,7 +224,7 @@ converse.plugins.add('converse-mam', {
function preMUCJoinMAMFetch (room) {
if (!_converse.muc_show_logs_before_join ||
!room.features.get('mam_enabled') ||
room.get('connection_status') !== converse.ROOMSTATUS.ENTERED ||
room.session.get('connection_status') !== converse.ROOMSTATUS.ENTERED ||
room.get('prejoin_mam_fetched')) {
return;
}
......
......@@ -322,6 +322,15 @@ converse.plugins.add('converse-muc', {
});
const MUCSession = Backbone.Model.extend({
defaults () {
return {
'connection_status': converse.ROOMSTATUS.DISCONNECTED
}
}
});
/**
* Collection which stores MUC messages
* @class
......@@ -357,7 +366,6 @@ converse.plugins.add('converse-muc', {
'bookmarked': false,
'chat_state': undefined,
'connection_status': converse.ROOMSTATUS.DISCONNECTED,
'description': '',
'hidden': ['mobile', 'fullscreen'].includes(_converse.view_mode),
'message_type': 'groupchat',
......@@ -372,12 +380,18 @@ converse.plugins.add('converse-muc', {
async initialize() {
this.initialized = u.getResolveablePromise();
const id = `muc.session-${this.get('jid')}`;
this.session = new MUCSession({id});
this.session.browserStorage = _converse.createStore(id, "session");
await new Promise(r => this.session.fetch({'success': r, 'error': r}));
this.setVCard();
this.set('box_id', `box-${btoa(this.get('jid'))}`);
this.initFeatures(); // sendChatState depends on this.features
this.on('change:chat_state', this.sendChatState, this);
this.on('change:connection_status', this.onConnectionStatusChanged, this);
this.session.on('change:connection_status', this.onConnectionStatusChanged, this);
this.initMessages();
this.initOccupants();
......@@ -405,7 +419,7 @@ converse.plugins.add('converse-muc', {
* @returns { Boolean } Returns `true` if we're still joined, otherwise returns `false`.
*/
async restoreFromCache () {
if (this.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();
......@@ -425,7 +439,7 @@ converse.plugins.add('converse-muc', {
* @param { String } [password] - Optional password, if required by the groupchat.
*/
async join (nick, password) {
if (this.get('connection_status') === converse.ROOMSTATUS.ENTERED) {
if (this.session.get('connection_status') === converse.ROOMSTATUS.ENTERED) {
// We have restored a groupchat from session storage,
// so we don't send out a presence stanza again.
return this;
......@@ -433,7 +447,7 @@ converse.plugins.add('converse-muc', {
await this.refreshRoomFeatures();
nick = await this.getAndPersistNickname(nick);
if (!nick) {
u.safeSave(this, {'connection_status': converse.ROOMSTATUS.NICKNAME_REQUIRED});
u.safeSave(this.session, {'connection_status': converse.ROOMSTATUS.NICKNAME_REQUIRED});
if (_converse.muc_show_logs_before_join) {
await this.fetchMessages();
}
......@@ -448,13 +462,13 @@ converse.plugins.add('converse-muc', {
if (password) {
stanza.cnode(Strophe.xmlElement("password", [], password));
}
this.save('connection_status', converse.ROOMSTATUS.CONNECTING);
this.session.save('connection_status', converse.ROOMSTATUS.CONNECTING);
_converse.api.send(stanza);
return this;
},
async clearCache () {
this.save('connection_status', converse.ROOMSTATUS.DISCONNECTED);
this.session.save('connection_status', converse.ROOMSTATUS.DISCONNECTED);
if (this.occupants.length) {
// Remove non-members when reconnecting
this.occupants.filter(o => !o.isMember()).forEach(o => o.destroy());
......@@ -478,7 +492,7 @@ converse.plugins.add('converse-muc', {
},
async onConnectionStatusChanged () {
if (this.get('connection_status') === converse.ROOMSTATUS.ENTERED) {
if (this.session.get('connection_status') === converse.ROOMSTATUS.ENTERED) {
if (_converse.muc_fetch_members) {
await this.occupants.fetchMembers();
}
......@@ -739,18 +753,21 @@ converse.plugins.add('converse-muc', {
if (_converse.api.connection.connected()) {
this.sendUnavailablePresence(exit_msg);
}
u.safeSave(this, {'connection_status': converse.ROOMSTATUS.DISCONNECTED});
u.safeSave(this.session, {'connection_status': converse.ROOMSTATUS.DISCONNECTED});
this.removeHandlers();
},
async close () {
try {
await new Promise((success, reject) => {
return this.features.destroy({success, 'error': (m, e) => reject(e)})
});
} catch (e) {
log.error(e);
}
// Delete the session model
await new Promise(resolve => this.session.destroy({
'success': resolve,
'error': (m, e) => { log.error(e); resolve() }
}));
// Delete the features model
await new Promise(resolve => this.features.destroy({
'success': resolve,
'error': (m, e) => { log.error(e); resolve() }
}));
return _converse.ChatBox.prototype.close.call(this);
},
......@@ -878,7 +895,7 @@ converse.plugins.add('converse-muc', {
sendChatState () {
if (!_converse.send_chat_state_notifications ||
!this.get('chat_state') ||
this.get('connection_status') !== converse.ROOMSTATUS.ENTERED ||
this.session.get('connection_status') !== converse.ROOMSTATUS.ENTERED ||
this.features.get('moderated') && this.getOwnRole() === 'visitor') {
return;
}
......@@ -1762,7 +1779,7 @@ converse.plugins.add('converse-muc', {
handleModifyError(pres) {
const text = get(pres.querySelector('error text'), 'textContent');
if (text) {
if (this.get('connection_status') === converse.ROOMSTATUS.CONNECTING) {
if (this.session.get('connection_status') === converse.ROOMSTATUS.CONNECTING) {
this.setDisconnectionMessage(text);
} else {
const attrs = {
......@@ -1858,11 +1875,11 @@ converse.plugins.add('converse-muc', {
setDisconnectionMessage (message, reason, actor) {
this.save({
'connection_status': converse.ROOMSTATUS.DISCONNECTED,
'disconnection_message': message,
'disconnection_reason': reason,
'disconnection_actor': actor
});
this.session.save({'connection_status': converse.ROOMSTATUS.DISCONNECTED});
},
......@@ -1880,9 +1897,10 @@ converse.plugins.add('converse-muc', {
this.save({
'nickname_validation_message': __(
"The nickname you chose is reserved or "+
"currently in use, please choose a different one."),
'connection_status': converse.ROOMSTATUS.NICKNAME_REQUIRED
"currently in use, please choose a different one."
)
});
this.session.save({'connection_status': converse.ROOMSTATUS.NICKNAME_REQUIRED});
}
},
......@@ -1903,10 +1921,8 @@ converse.plugins.add('converse-muc', {
this.handleModifyError(stanza);
} else if (error_type === 'auth') {
if (sizzle(`not-authorized[xmlns="${Strophe.NS.STANZAS}"]`, error).length) {
this.save({
'password_validation_message': reason || __("Password incorrect"),
'connection_status': converse.ROOMSTATUS.PASSWORD_REQUIRED
});
this.save({'password_validation_message': reason || __("Password incorrect")});
this.session.save({'connection_status': converse.ROOMSTATUS.PASSWORD_REQUIRED});
}
if (error.querySelector('registration-required')) {
const message = __('You are not on the member list of this groupchat.');
......@@ -1926,11 +1942,8 @@ converse.plugins.add('converse-muc', {
const moved_jid = get(sizzle(`gone[xmlns="${Strophe.NS.STANZAS}"]`, error).pop(), 'textContent')
.replace(/^xmpp:/, '')
.replace(/\?join$/, '');
this.save({
'connection_status': converse.ROOMSTATUS.DESTROYED,
'destroyed_reason': reason,
'moved_jid': moved_jid
});
this.save({ moved_jid, 'destroyed_reason': reason});
this.session.save({'connection_status': converse.ROOMSTATUS.DESTROYED});
} else if (error.querySelector('conflict')) {
this.onNicknameClash(stanza);
} else if (error.querySelector('item-not-found')) {
......@@ -1962,8 +1975,8 @@ converse.plugins.add('converse-muc', {
if (stanza.querySelector("status[code='110']")) {
this.onOwnPresence(stanza);
if (this.getOwnRole() !== 'none' &&
this.get('connection_status') === converse.ROOMSTATUS.CONNECTING) {
this.save('connection_status', converse.ROOMSTATUS.CONNECTED);
this.session.get('connection_status') === converse.ROOMSTATUS.CONNECTING) {
this.session.save('connection_status', converse.ROOMSTATUS.CONNECTED);
}
} else {
this.updateOccupantsOnPresence(stanza);
......@@ -1987,7 +2000,7 @@ converse.plugins.add('converse-muc', {
*/
onOwnPresence (stanza) {
if (stanza.getAttribute('type') !== 'unavailable') {
this.save('connection_status', converse.ROOMSTATUS.ENTERED);
this.session.save('connection_status', converse.ROOMSTATUS.ENTERED);
}
this.updateOccupantsOnPresence(stanza);
......@@ -2026,7 +2039,7 @@ converse.plugins.add('converse-muc', {
}
}
}
this.save({'connection_status': converse.ROOMSTATUS.ENTERED});
this.session.save({'connection_status': converse.ROOMSTATUS.ENTERED});
},
/**
......@@ -2247,7 +2260,7 @@ converse.plugins.add('converse-muc', {
}
if (result === true) {
const chatroom = await openChatRoom(room_jid, {'password': x_el.getAttribute('password') });
if (chatroom.get('connection_status') === converse.ROOMSTATUS.DISCONNECTED) {
if (chatroom.session.get('connection_status') === converse.ROOMSTATUS.DISCONNECTED) {
_converse.chatboxes.get(room_jid).rejoin();
}
}
......@@ -2311,7 +2324,7 @@ converse.plugins.add('converse-muc', {
/************************ BEGIN Event Handlers ************************/
_converse.api.listen.on('beforeTearDown', () => {
const groupchats = _converse.chatboxes.where({'type': _converse.CHATROOMS_TYPE});
groupchats.forEach(gc => u.safeSave(gc, {'connection_status': converse.ROOMSTATUS.DISCONNECTED}));
groupchats.forEach(muc => u.safeSave(muc.session, {'connection_status': converse.ROOMSTATUS.DISCONNECTED}));
});
_converse.api.listen.on('windowStateChanged', onWindowStateChanged);
......@@ -2334,7 +2347,7 @@ converse.plugins.add('converse-muc', {
*/
return _converse.chatboxes
.filter(m => (m.get('type') === _converse.CHATROOMS_TYPE))
.forEach(m => m.save({'connection_status': converse.ROOMSTATUS.DISCONNECTED}));
.forEach(m => m.session.save({'connection_status': converse.ROOMSTATUS.DISCONNECTED}));
}
_converse.api.listen.on('disconnected', disconnectChatRooms);
......
......@@ -286,7 +286,6 @@
}).up()
.c('status').attrs({code:'110'});
_converse.connection._dataRecv(utils.createRequest(presence));
// return utils.waitUntil(() => (view.model.get('connection_status') === converse.ROOMSTATUS.ENTERED));
};
......@@ -302,7 +301,7 @@
await room_creation_promise;
const view = _converse.chatboxviews.get(muc_jid);
await u.waitUntil(() => (view.model.get('connection_status') === converse.ROOMSTATUS.ENTERED));
await u.waitUntil(() => (view.model.session.get('connection_status') === converse.ROOMSTATUS.ENTERED));
if (_converse.muc_fetch_members) {
await utils.returnMemberLists(_converse, muc_jid, members);
}
......
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