Commit 9c812157 authored by JC Brand's avatar JC Brand

Use async/await

parent 93bfa3bb
......@@ -62996,14 +62996,14 @@ function cleanup() {
_converse.connection.reset();
_converse.tearDown();
_converse.stopListening();
_converse.tearDown();
_converse.off();
delete _converse.config;
initClientConfig();
_converse.off();
}
_converse.initialize = function (settings, callback) {
......@@ -64575,12 +64575,15 @@ _converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins.add('converse-dis
}
},
queryInfo() {
_converse.api.disco.info(this.get('jid'), null).then(stanza => this.onInfo(stanza)).catch(iq => {
async queryInfo() {
try {
const stanza = await _converse.api.disco.info(this.get('jid'), null);
this.onInfo(stanza);
} catch (iq) {
this.waitUntilFeaturesDiscovered.resolve(this);
_converse.log(iq, Strophe.LogLevel.ERROR);
});
}
},
onDiscoItems(stanza) {
......@@ -1626,26 +1626,19 @@
null, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) {
let sent_IQ, IQ_id;
const IQ_stanzas = _converse.connection.IQ_stanzas;
const sendIQ = _converse.connection.sendIQ;
const room_jid = 'lounge@localhost';
spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
if (iq.nodeTree.getAttribute('to') === 'lounge@localhost') {
sent_IQ = iq;
IQ_id = sendIQ.bind(this)(iq, callback, errback);
} else {
sendIQ.bind(this)(iq, callback, errback);
}
});
await test_utils.openChatRoom(_converse, 'lounge', 'localhost', 'dummy');
let stanza = await test_utils.waitUntil(() => _.get(_.filter(
IQ_stanzas,
iq => iq.nodeTree.querySelector(
`iq[to="${room_jid}"] query[xmlns="http://jabber.org/protocol/disco#info"]`
)).pop(), 'nodeTree')
);
// We pretend this is a new room, so no disco info is returned.
const features_stanza = $iq({
from: 'lounge@localhost',
......@@ -1693,7 +1686,7 @@
*/
stanza = $iq({
'type': 'result',
'id': IQ_id,
'id': node.nodeTree.getAttribute('id'),
'from': view.model.get('jid'),
'to': _converse.connection.jid
}).c('query', {'xmlns': 'http://jabber.org/protocol/disco#info', 'node': 'x-roomuser-item'})
......
......@@ -134,13 +134,14 @@ converse.plugins.add('converse-disco', {
}
},
queryInfo () {
_converse.api.disco.info(this.get('jid'), null)
.then(stanza => this.onInfo(stanza))
.catch(iq => {
async queryInfo () {
try {
const stanza = await _converse.api.disco.info(this.get('jid'), null);
this.onInfo(stanza);
} catch(iq) {
this.waitUntilFeaturesDiscovered.resolve(this);
_converse.log(iq, Strophe.LogLevel.ERROR);
});
}
},
onDiscoItems (stanza) {
......
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