Commit 1a7a5e80 authored by JC Brand's avatar JC Brand

Add a spinner when loading during infinite scrolling.

updates #306
parent ec02d34a
......@@ -1281,6 +1281,7 @@
if ($(ev.target).scrollTop() === 0) {
oldest = this.model.messages.where({'time': this.model.messages.pluck('time').sort()[0]});
if (oldest) {
this.$el.find('.chat-content').prepend('<span class="spinner"/>');
this.fetchArchivedMessages({
'before': oldest[0].get('archive_id'),
'with': this.model.get('jid'),
......@@ -1343,7 +1344,12 @@
* so that they are displayed inside it.
*/
API.archive.query(options,
_.partial(_.map, _, converse.chatboxes.onMessage.bind(converse.chatboxes)),
function (messages) {
this.clearSpinner();
if (messages.length) {
_.map(messages, converse.chatboxes.onMessage.bind(converse.chatboxes));
}
}.bind(this),
_.partial(converse.log, "Error while trying to fetch archived messages", "error")
);
},
......@@ -1379,6 +1385,13 @@
return this;
},
clearSpinner: function () {
var $content = this.$el.find('.chat-content');
if ($content.children(':first').is('span.spinner')) {
$content.children(':first').first().remove();
}
},
showMessage: function (msg_dict) {
var $content = this.$el.find('.chat-content'),
msg_time = moment(msg_dict.time) || moment,
......
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