Do disco check in fetchArchivedMessages
so that it's applied in all cases where archived messages are fetched.
This commit is contained in:
parent
d42b872795
commit
dbee62c794
@ -152,13 +152,9 @@
|
||||
* the last archived message in our local cache.
|
||||
*/
|
||||
if (this.disable_mam) { return; }
|
||||
const { _converse } = this.__super__;
|
||||
const mam_jid = this.model.get('type') === CHATROOMS_TYPE ? this.model.get('jid') : _converse.bare_jid;
|
||||
const { _converse } = this.__super__,
|
||||
most_recent_msg = utils.getMostRecentMessage(this.model);
|
||||
|
||||
_converse.api.disco.supports(Strophe.NS.MAM, mam_jid).then(
|
||||
(results) => { // Success
|
||||
if (results.length) {
|
||||
const most_recent_msg = utils.getMostRecentMessage(this.model);
|
||||
if (_.isNil(most_recent_msg)) {
|
||||
this.fetchArchivedMessages();
|
||||
} else {
|
||||
@ -173,18 +169,6 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
() => { // Error
|
||||
_converse.log(
|
||||
"Error or timeout while checking for MAM support",
|
||||
Strophe.LogLevel.ERROR
|
||||
);
|
||||
}
|
||||
).catch((msg) => {
|
||||
this.clearSpinner();
|
||||
_converse.log(msg, Strophe.LogLevel.FATAL);
|
||||
});
|
||||
},
|
||||
|
||||
fetchArchivedMessagesIfNecessary () {
|
||||
@ -319,8 +303,12 @@
|
||||
* Then, upon receiving them, call onMessage
|
||||
* so that they are displayed inside it.
|
||||
*/
|
||||
const that = this;
|
||||
const { _converse } = this.__super__;
|
||||
const { _converse } = this.__super__,
|
||||
mam_jid = this.model.get('type') === CHATROOMS_TYPE ? this.model.get('jid') : _converse.bare_jid;
|
||||
|
||||
_converse.api.disco.supports(Strophe.NS.MAM, mam_jid).then(
|
||||
(results) => { // Success
|
||||
if (!results.length) { return; }
|
||||
this.addSpinner();
|
||||
_converse.api.archive.query(
|
||||
_.extend({
|
||||
@ -329,20 +317,30 @@
|
||||
'with': this.model.get('jid'),
|
||||
'max': _converse.archived_messages_page_size
|
||||
}, options),
|
||||
function (messages) {
|
||||
that.clearSpinner();
|
||||
(messages) => {
|
||||
this.clearSpinner();
|
||||
if (messages.length) {
|
||||
_.each(messages, that.model.onMessage.bind(that.model));
|
||||
_.each(messages, this.model.onMessage.bind(this.model));
|
||||
}
|
||||
},
|
||||
function () {
|
||||
that.clearSpinner();
|
||||
() => {
|
||||
this.clearSpinner();
|
||||
_converse.log(
|
||||
"Error while trying to fetch archived messages",
|
||||
Strophe.LogLevel.WARN);
|
||||
}
|
||||
);
|
||||
},
|
||||
() => { // Error
|
||||
_converse.log(
|
||||
"Error or timeout while checking for MAM support",
|
||||
Strophe.LogLevel.ERROR
|
||||
);
|
||||
}
|
||||
).catch((msg) => {
|
||||
this.clearSpinner();
|
||||
_converse.log(msg, Strophe.LogLevel.FATAL);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user