Commit 9500900f authored by JC Brand's avatar JC Brand

Make sure bookmarks are cleared before re-initializing

Otherwise subtle, hard-to-reproduce bugs happen while testing.

Also, don't unnecessarily call `delegateEvents`, it also causes
heisen-breakage.
parent 36fd859a
...@@ -66,7 +66,6 @@ ...@@ -66,7 +66,6 @@
cbview.el.querySelector('input[name="password"]').value = 'secret'; cbview.el.querySelector('input[name="password"]').value = 'secret';
spyOn(cbview.loginpanel, 'connect'); spyOn(cbview.loginpanel, 'connect');
cbview.delegateEvents();
expect(_converse.storage).toBe('session'); expect(_converse.storage).toBe('session');
cbview.el.querySelector('input[type="submit"]').click(); cbview.el.querySelector('input[type="submit"]').click();
......
...@@ -252,6 +252,9 @@ ...@@ -252,6 +252,9 @@
// This happens in tests. We therefore first clean up. // This happens in tests. We therefore first clean up.
Backbone.history.stop(); Backbone.history.stop();
_converse.chatboxviews.closeAllChatBoxes(); _converse.chatboxviews.closeAllChatBoxes();
if (_converse.bookmarks) {
_converse.bookmarks.reset();
}
delete _converse.controlboxtoggle; delete _converse.controlboxtoggle;
delete _converse.chatboxviews; delete _converse.chatboxviews;
_converse.connection.reset(); _converse.connection.reset();
......
...@@ -131,7 +131,7 @@ ...@@ -131,7 +131,7 @@
_converse.api.rooms.open(`${room}@${server}`); _converse.api.rooms.open(`${room}@${server}`);
const view = _converse.chatboxviews.get((room+'@'+server).toLowerCase()); const view = _converse.chatboxviews.get((room+'@'+server).toLowerCase());
// We pretend this is a new room, so no disco info is returned. // We pretend this is a new room, so no disco info is returned.
last_stanza = _.last(_converse.connection.IQ_stanzas).nodeTree; let last_stanza = _.last(_converse.connection.IQ_stanzas).nodeTree;
const IQ_id = last_stanza.getAttribute('id'); const IQ_id = last_stanza.getAttribute('id');
const features_stanza = $iq({ const features_stanza = $iq({
'from': room+'@'+server, 'from': room+'@'+server,
...@@ -146,15 +146,12 @@ ...@@ -146,15 +146,12 @@
return _.filter( return _.filter(
_converse.connection.IQ_stanzas, (node) => { _converse.connection.IQ_stanzas, (node) => {
const query = node.nodeTree.querySelector('query'); const query = node.nodeTree.querySelector('query');
return query && query.getAttribute('node') === 'x-roomuser-item' if (query && query.getAttribute('node') === 'x-roomuser-item') {
last_stanza = node.nodeTree;
return true;
}
}).length }).length
}).then(function () { }).then(function () {
const last_stanza = _.filter(
_converse.connection.IQ_stanzas, (node) => {
const query = node.nodeTree.querySelector('query');
return query && query.getAttribute('node') === 'x-roomuser-item'
}).pop().nodeTree;
// The XMPP server returns the reserved nick for this user. // The XMPP server returns the reserved nick for this user.
const IQ_id = last_stanza.getAttribute('id'); const IQ_id = last_stanza.getAttribute('id');
const stanza = $iq({ const stanza = $iq({
...@@ -181,8 +178,9 @@ ...@@ -181,8 +178,9 @@
.c('status').attrs({code:'110'}); .c('status').attrs({code:'110'});
_converse.connection._dataRecv(utils.createRequest(presence)); _converse.connection._dataRecv(utils.createRequest(presence));
resolve(); resolve();
});
}); }).catch(_.partial(console.error, _));
}).catch(_.partial(console.error, _));
}; };
utils.clearBrowserStorage = function () { utils.clearBrowserStorage = function () {
......
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