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);
......
This diff is collapsed.
......@@ -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;
}
......
This diff is collapsed.
......@@ -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