Don't attempt to fetch archived messages if not supported

by the server. Otherwise we get a spinner that doesn't disappear.
This commit is contained in:
JC Brand 2015-10-12 13:19:46 +00:00
parent 57a309177f
commit 7d1fc391ac
2 changed files with 12 additions and 3 deletions

View File

@ -1250,9 +1250,6 @@
onScroll: function (ev) { onScroll: function (ev) {
if ($(ev.target).scrollTop() === 0 && this.model.messages.length) { if ($(ev.target).scrollTop() === 0 && this.model.messages.length) {
if (!this.$content.first().hasClass('spinner')) {
this.$content.prepend('<span class="spinner"/>');
}
this.fetchArchivedMessages({ this.fetchArchivedMessages({
'before': this.model.messages.at(0).get('archive_id'), 'before': this.model.messages.at(0).get('archive_id'),
'with': this.model.get('jid'), 'with': this.model.get('jid'),
@ -1291,6 +1288,11 @@
* Then, upon receiving them, call onMessage on the chat box, * Then, upon receiving them, call onMessage on the chat box,
* so that they are displayed inside it. * so that they are displayed inside it.
*/ */
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();
API.archive.query(_.extend(options, {'groupchat': this.is_chatroom}), API.archive.query(_.extend(options, {'groupchat': this.is_chatroom}),
function (messages) { function (messages) {
this.clearSpinner(); this.clearSpinner();
@ -1347,6 +1349,12 @@
return this; return this;
}, },
addSpinner: function () {
if (!this.$content.first().hasClass('spinner')) {
this.$content.prepend('<span class="spinner"/>');
}
},
clearSpinner: function () { clearSpinner: function () {
if (this.$content.children(':first').is('span.spinner')) { if (this.$content.children(':first').is('span.spinner')) {
this.$content.children(':first').remove(); this.$content.children(':first').remove();

View File

@ -8,6 +8,7 @@ Changelog
* #468 Fix [object Object] being sometimes shown as status [1st8] * #468 Fix [object Object] being sometimes shown as status [1st8]
* #493 Roster wasn't being updated after a Roster push update [teseo, jcbrand] * #493 Roster wasn't being updated after a Roster push update [teseo, jcbrand]
* #496 Bugfix. Pings weren't being sent out. [teseo, jcbrand] * #496 Bugfix. Pings weren't being sent out. [teseo, jcbrand]
* Bugfix. Spinner doesn't disappear when scrolling up (when server doesn't support XEP-0313). [jcbrand]
0.9.5 (2015-08-24) 0.9.5 (2015-08-24)
------------------ ------------------