Move MAM code to proper place.
Also, don't query for MAM messages if the chat room doesn't support it.
This commit is contained in:
parent
0d48929bb3
commit
61b2dc7f99
@ -86,12 +86,14 @@
|
||||
fetchArchivedMessages: function (options) {
|
||||
/* Fetch archived chat messages from the XMPP server.
|
||||
*
|
||||
* Then, upon receiving them, call onMessage on the chat box,
|
||||
* so that they are displayed inside it.
|
||||
* Then, upon receiving them, call onMessage on the chat
|
||||
* box, so that they are displayed inside it.
|
||||
*/
|
||||
var _converse = this.__super__._converse;
|
||||
if (!_converse.features.findWhere({'var': Strophe.NS.MAM})) {
|
||||
_converse.log("Attempted to fetch archived messages but this user's server doesn't support XEP-0313");
|
||||
_converse.log(
|
||||
"Attempted to fetch archived messages but this "+
|
||||
"user's server doesn't support XEP-0313");
|
||||
return;
|
||||
}
|
||||
if (this.disable_mam) {
|
||||
@ -106,7 +108,9 @@
|
||||
}.bind(this),
|
||||
function () {
|
||||
this.clearSpinner();
|
||||
_converse.log("Error or timeout while trying to fetch archived messages", "error");
|
||||
_converse.log(
|
||||
"Error or timeout while trying to fetch "+
|
||||
"archived messages", "error");
|
||||
}.bind(this)
|
||||
);
|
||||
},
|
||||
@ -132,8 +136,40 @@
|
||||
return result;
|
||||
},
|
||||
|
||||
fetchArchivedMessages: function (options) {
|
||||
/* Fetch archived chat messages from the XMPP server.
|
||||
*
|
||||
* Then, upon receiving them, call onChatRoomMessage
|
||||
* so that they are displayed inside it.
|
||||
*/
|
||||
var that = this;
|
||||
var _converse = this.__super__._converse;
|
||||
if (!_converse.features.findWhere({'var': Strophe.NS.MAM})) {
|
||||
_converse.log(
|
||||
"Attempted to fetch archived messages but this "+
|
||||
"user's server doesn't support XEP-0313");
|
||||
return;
|
||||
}
|
||||
if (!this.model.get('mam_enabled')) {
|
||||
return;
|
||||
}
|
||||
this.addSpinner();
|
||||
_converse.api.archive.query(_.extend(options, {'groupchat': true}),
|
||||
function (messages) {
|
||||
that.clearSpinner();
|
||||
if (messages.length) {
|
||||
_.each(messages, that.onChatRoomMessage.bind(that));
|
||||
}
|
||||
},
|
||||
function () {
|
||||
that.clearSpinner();
|
||||
_converse.log(
|
||||
"Error while trying to fetch archived messages",
|
||||
"error");
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
||||
|
@ -1888,32 +1888,6 @@
|
||||
_converse.emit('message', message);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
fetchArchivedMessages: function (options) {
|
||||
/* Fetch archived chat messages from the XMPP server.
|
||||
*
|
||||
* Then, upon receiving them, call onChatRoomMessage
|
||||
* so that they are displayed inside it.
|
||||
*/
|
||||
var that = this;
|
||||
if (!_converse.features.findWhere({'var': Strophe.NS.MAM})) {
|
||||
_converse.log("Attempted to fetch archived messages but this user's server doesn't support XEP-0313");
|
||||
return;
|
||||
}
|
||||
this.addSpinner();
|
||||
_converse.api.archive.query(_.extend(options, {'groupchat': true}),
|
||||
function (messages) {
|
||||
that.clearSpinner();
|
||||
if (messages.length) {
|
||||
_.each(messages, that.onChatRoomMessage.bind(that));
|
||||
}
|
||||
},
|
||||
function () {
|
||||
that.clearSpinner();
|
||||
_converse.log("Error while trying to fetch archived messages", "error");
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user