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