Commit fa85fc71 authored by JC Brand's avatar JC Brand

Use async/await

parent 76b32bea
...@@ -52439,7 +52439,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins ...@@ -52439,7 +52439,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
}); });
}, },
fetchArchivedMessages(options) { async fetchArchivedMessages(options) {
const _converse = this.__super__._converse; const _converse = this.__super__._converse;
if (this.disable_mam) { if (this.disable_mam) {
...@@ -52457,17 +52457,15 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins ...@@ -52457,17 +52457,15 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
message_handler = _converse.chatboxes.onMessage.bind(_converse.chatboxes); message_handler = _converse.chatboxes.onMessage.bind(_converse.chatboxes);
} }
_converse.api.disco.supports(Strophe.NS.MAM, mam_jid).then(results => { const supported = await _converse.api.disco.supports(Strophe.NS.MAM, mam_jid);
// Success
if (!results.length) { if (!supported.length) {
return; return;
} }
this.addSpinner(); this.addSpinner();
_converse.api.archive.query( // TODO: only query from the last message we have _converse.api.archive.query(_.extend({
// in our history
_.extend({
'groupchat': is_groupchat, 'groupchat': is_groupchat,
'before': '', 'before': '',
// Page backwards from the most recent message // Page backwards from the most recent message
...@@ -52486,14 +52484,6 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins ...@@ -52486,14 +52484,6 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
_converse.log(e, Strophe.LogLevel.ERROR); _converse.log(e, Strophe.LogLevel.ERROR);
}); });
}, () => {
// Error
_converse.log("Error or timeout while checking for MAM support", Strophe.LogLevel.ERROR);
}).catch(msg => {
this.clearSpinner();
_converse.log(msg, Strophe.LogLevel.FATAL);
});
}, },
onScroll(ev) { onScroll(ev) {
...@@ -80,7 +80,7 @@ converse.plugins.add('converse-mam-views', { ...@@ -80,7 +80,7 @@ converse.plugins.add('converse-mam-views', {
}); });
}, },
fetchArchivedMessages (options) { async fetchArchivedMessages (options) {
const { _converse } = this.__super__; const { _converse } = this.__super__;
if (this.disable_mam) { return; } if (this.disable_mam) { return; }
...@@ -95,20 +95,20 @@ converse.plugins.add('converse-mam-views', { ...@@ -95,20 +95,20 @@ converse.plugins.add('converse-mam-views', {
message_handler = _converse.chatboxes.onMessage.bind(_converse.chatboxes) message_handler = _converse.chatboxes.onMessage.bind(_converse.chatboxes)
} }
_converse.api.disco.supports(Strophe.NS.MAM, mam_jid).then( const supported = await _converse.api.disco.supports(Strophe.NS.MAM, mam_jid);
(results) => { // Success if (!supported.length) {
if (!results.length) { return; } return;
}
this.addSpinner(); this.addSpinner();
_converse.api.archive.query( _converse.api.archive.query(
// TODO: only query from the last message we have
// in our history
_.extend({ _.extend({
'groupchat': is_groupchat, 'groupchat': is_groupchat,
'before': '', // Page backwards from the most recent message 'before': '', // Page backwards from the most recent message
'max': _converse.archived_messages_page_size, 'max': _converse.archived_messages_page_size,
'with': this.model.get('jid'), 'with': this.model.get('jid'),
}, options), }, options),
(messages) => { // Success
messages => { // Success
this.clearSpinner(); this.clearSpinner();
_.each(messages, message_handler); _.each(messages, message_handler);
}, },
...@@ -121,17 +121,6 @@ converse.plugins.add('converse-mam-views', { ...@@ -121,17 +121,6 @@ converse.plugins.add('converse-mam-views', {
} }
); );
}, },
() => { // Error
_converse.log(
"Error or timeout while checking for MAM support",
Strophe.LogLevel.ERROR
);
}
).catch((msg) => {
this.clearSpinner();
_converse.log(msg, Strophe.LogLevel.FATAL);
});
},
onScroll (ev) { onScroll (ev) {
const { _converse } = this.__super__; const { _converse } = this.__super__;
......
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