Use async/await
This commit is contained in:
parent
76b32bea92
commit
fa85fc71b9
20
dist/converse.js
vendored
20
dist/converse.js
vendored
@ -52439,7 +52439,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
|
||||
});
|
||||
},
|
||||
|
||||
fetchArchivedMessages(options) {
|
||||
async fetchArchivedMessages(options) {
|
||||
const _converse = this.__super__._converse;
|
||||
|
||||
if (this.disable_mam) {
|
||||
@ -52457,17 +52457,15 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
|
||||
message_handler = _converse.chatboxes.onMessage.bind(_converse.chatboxes);
|
||||
}
|
||||
|
||||
_converse.api.disco.supports(Strophe.NS.MAM, mam_jid).then(results => {
|
||||
// Success
|
||||
if (!results.length) {
|
||||
const supported = await _converse.api.disco.supports(Strophe.NS.MAM, mam_jid);
|
||||
|
||||
if (!supported.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.addSpinner();
|
||||
|
||||
_converse.api.archive.query( // TODO: only query from the last message we have
|
||||
// in our history
|
||||
_.extend({
|
||||
_converse.api.archive.query(_.extend({
|
||||
'groupchat': is_groupchat,
|
||||
'before': '',
|
||||
// Page backwards from the most recent message
|
||||
@ -52486,14 +52484,6 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
|
||||
|
||||
_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) {
|
||||
|
@ -80,7 +80,7 @@ converse.plugins.add('converse-mam-views', {
|
||||
});
|
||||
},
|
||||
|
||||
fetchArchivedMessages (options) {
|
||||
async fetchArchivedMessages (options) {
|
||||
const { _converse } = this.__super__;
|
||||
if (this.disable_mam) { return; }
|
||||
|
||||
@ -95,20 +95,20 @@ converse.plugins.add('converse-mam-views', {
|
||||
message_handler = _converse.chatboxes.onMessage.bind(_converse.chatboxes)
|
||||
}
|
||||
|
||||
_converse.api.disco.supports(Strophe.NS.MAM, mam_jid).then(
|
||||
(results) => { // Success
|
||||
if (!results.length) { return; }
|
||||
const supported = await _converse.api.disco.supports(Strophe.NS.MAM, mam_jid);
|
||||
if (!supported.length) {
|
||||
return;
|
||||
}
|
||||
this.addSpinner();
|
||||
_converse.api.archive.query(
|
||||
// TODO: only query from the last message we have
|
||||
// in our history
|
||||
_.extend({
|
||||
'groupchat': is_groupchat,
|
||||
'before': '', // Page backwards from the most recent message
|
||||
'max': _converse.archived_messages_page_size,
|
||||
'with': this.model.get('jid'),
|
||||
}, options),
|
||||
(messages) => { // Success
|
||||
|
||||
messages => { // Success
|
||||
this.clearSpinner();
|
||||
_.each(messages, message_handler);
|
||||
},
|
||||
@ -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) {
|
||||
const { _converse } = this.__super__;
|
||||
|
Loading…
Reference in New Issue
Block a user