Commit 65190834 authored by JC Brand's avatar JC Brand

Revert to explicit Promise-based code.

* src/converse-controlbox.js

    async/await causes many tests here to fail due to the controlbox toggle
    now apparently showing up a little later (and the tests don't wait for
    it to happen).

* src/converse-minimize.js

    We get timeout issues in tests.

* src/headless/converse-chatboxes.js

    We get a stack overflow while running tests.
parent 7a1f62d3
......@@ -154,7 +154,7 @@ converse.plugins.add('converse-controlbox', {
}
},
async initialize () {
initialize () {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
......@@ -238,13 +238,14 @@ converse.plugins.add('converse-controlbox', {
}
},
async insertRoster () {
insertRoster () {
if (_converse.authentication === _converse.ANONYMOUS) {
return;
}
/* Place the rosterview inside the "Contacts" panel. */
await _converse.api.waitUntil('rosterViewInitialized');
this.controlbox_pane.el.insertAdjacentElement('beforeEnd', _converse.rosterview.el);
_converse.api.waitUntil('rosterViewInitialized')
.then(() => this.controlbox_pane.el.insertAdjacentElement('beforeEnd', _converse.rosterview.el))
.catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
},
createBrandHeadingHTML () {
......@@ -505,10 +506,11 @@ converse.plugins.add('converse-controlbox', {
'href': "#"
},
async initialize () {
initialize () {
_converse.chatboxviews.insertRowColumn(this.render().el);
await _converse.api.waitUntil('initialized');
this.render.bind(this);
_converse.api.waitUntil('initialized')
.then(this.render.bind(this))
.catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
},
render () {
......@@ -587,11 +589,10 @@ converse.plugins.add('converse-controlbox', {
}
});
await Promise.all([
Promise.all([
_converse.api.waitUntil('connectionInitialized'),
_converse.api.waitUntil('chatBoxViewsInitialized')
]);
_converse.addControlBox();
]).then(_converse.addControlBox).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
_converse.on('chatBoxesFetched', () => {
const controlbox = _converse.chatboxes.get('controlbox') || _converse.addControlBox();
......
......@@ -299,7 +299,7 @@ converse.plugins.add('converse-minimize', {
},
async initialize () {
initialize () {
/* The initialize function gets called as soon as the plugin is
* loaded by Converse.js's plugin machinery.
*/
......@@ -509,12 +509,16 @@ converse.plugins.add('converse-minimize', {
}
});
await _converse.api.waitUntil('connectionInitialized');
await _converse.api.waitUntil('chatBoxViewsInitialized');
_converse.minimized_chats = new _converse.MinimizedChats({
model: _converse.chatboxes
});
_converse.emit('minimizedChatsInitialized');
Promise.all([
_converse.api.waitUntil('connectionInitialized'),
_converse.api.waitUntil('chatBoxViewsInitialized')
]).then(() => {
_converse.minimized_chats = new _converse.MinimizedChats({
model: _converse.chatboxes
});
_converse.emit('minimizedChatsInitialized');
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
_converse.on('registeredGlobalEventHandlers', function () {
window.addEventListener("resize", _.debounce(function (ev) {
......
......@@ -653,7 +653,7 @@ converse.plugins.add('converse-chatboxes', {
}
},
async onMessage (stanza) {
onMessage (stanza) {
/* Handler method for all incoming single-user chat "message"
* stanzas.
*
......@@ -727,8 +727,9 @@ converse.plugins.add('converse-chatboxes', {
message = msgid && chatbox.messages.findWhere({msgid});
if (!message) {
// Only create the message when we're sure it's not a duplicate
const msg = await chatbox.createMessage(stanza, original_stanza);
chatbox.incrementUnreadMsgCounter(msg);
chatbox.createMessage(stanza, original_stanza)
.then(msg => chatbox.incrementUnreadMsgCounter(msg))
.catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
}
}
_converse.emit('message', {'stanza': original_stanza, 'chatbox': chatbox});
......
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