Commit f24e7c09 authored by JC Brand's avatar JC Brand

Remove scrollDownMessageHeight. Fix failing test

parent 0bc0072f
......@@ -699,7 +699,7 @@
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree());
}
});
waits(50);
waits(500); // Give enough time for `markScrolled` to have been called
runs(function () {
chatboxview.$content.scrollTop(0);
});
......
......@@ -1089,8 +1089,8 @@
spyOn(view, 'scrollDown').andCallThrough();
runs(function () {
/* Create enough messages so that there's a
* scrollbar.
*/
* scrollbar.
*/
for (var i=0; i<20; i++) {
_converse.chatboxes.onMessage(
$msg({
......@@ -1101,7 +1101,7 @@
}).c('body').t('Message: '+i).tree());
}
});
waits(50);
waits(500); // Give enough time for `markScrolled` to have been called
runs(function () {
view.$content.scrollTop(0);
});
......
......@@ -221,7 +221,7 @@
insert.call(that.$content, $el);
return $el;
},
this.scrollDownMessageHeight.bind(this)
this.scrollDown.bind(this)
)(this.renderMessage(attrs));
},
......@@ -288,7 +288,7 @@
this.$content.find('.chat-message[data-isodate="'+msg_dates[idx]+'"]'));
return $el;
}.bind(this),
this.scrollDownMessageHeight.bind(this)
this.scrollDown.bind(this)
)(this.renderMessage(attrs));
},
......@@ -776,6 +776,13 @@
return this;
},
hideNewMessagesIndicator: function () {
var new_msgs_indicator = this.el.querySelector('.new-msgs-indicator');
if (!_.isNull(new_msgs_indicator)) {
new_msgs_indicator.classList.add('hidden');
}
},
markScrolled: _.debounce(function (ev) {
/* Called when the chat content is scrolled up or down.
* We want to record when the user has scrolled away from
......@@ -795,8 +802,8 @@
(this.$content.scrollTop() + this.$content.innerHeight()) >=
this.$content[0].scrollHeight-10;
if (is_at_bottom) {
this.hideNewMessagesIndicator();
this.model.save('scrolled', false);
this.$el.find('.new-msgs-indicator').addClass('hidden');
} else {
// We're not at the bottom of the chat area, so we mark
// that the box is in a scrolled-up state.
......@@ -809,20 +816,11 @@
this.scrollDown();
},
scrollDownMessageHeight: function ($message) {
if (this.$content.is(':visible') && !this.model.get('scrolled')) {
this.$content.scrollTop(
this.$content.scrollTop() + $message[0].scrollHeight);
this.model.save({'auto_scrolled': true});
}
return this;
},
_scrollDown: function () {
/* Inner method that gets debounced */
if (this.$content.is(':visible') && !this.model.get('scrolled')) {
this.$content.scrollTop(this.$content[0].scrollHeight);
this.$el.find('.new-msgs-indicator').addClass('hidden');
this.hideNewMessagesIndicator();
this.model.save({'auto_scrolled': true});
}
},
......
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