refactor: Early-exit in message_scroll.scroll_finished.

This is just cosmetic to flatten the function a bit.
This commit is contained in:
Steve Howell
2018-03-08 14:41:43 -05:00
committed by Tim Abbott
parent 8063f73f6d
commit b8f39b2ff1

View File

@@ -28,27 +28,31 @@ exports.actively_scrolling = function () {
exports.scroll_finished = function () { exports.scroll_finished = function () {
actively_scrolling = false; actively_scrolling = false;
if ($('#home').hasClass('active')) { if (!$('#home').hasClass('active')) {
if (!pointer.suppress_scroll_pointer_update) { return;
message_viewport.keep_pointer_in_view();
} else {
pointer.suppress_scroll_pointer_update = false;
}
floating_recipient_bar.update();
if (message_viewport.scrollTop() === 0) {
message_fetch.load_more_messages({
msg_list: current_msg_list,
show_loading: exports.show_loading_more_messages_indicator,
hide_loading: exports.hide_loading_more_messages_indicator,
});
}
// When the window scrolls, it may cause some messages to
// enter the screen and become read. Calling
// unread_ops.process_visible will update necessary
// data structures and DOM elements.
setTimeout(unread_ops.process_visible, 0);
} }
if (!pointer.suppress_scroll_pointer_update) {
message_viewport.keep_pointer_in_view();
} else {
pointer.suppress_scroll_pointer_update = false;
}
floating_recipient_bar.update();
if (message_viewport.scrollTop() === 0) {
message_fetch.load_more_messages({
msg_list: current_msg_list,
show_loading: exports.show_loading_more_messages_indicator,
hide_loading: exports.hide_loading_more_messages_indicator,
});
}
// When the window scrolls, it may cause some messages to
// enter the screen and become read. Calling
// unread_ops.process_visible will update necessary
// data structures and DOM elements.
setTimeout(unread_ops.process_visible, 0);
}; };
var scroll_timer; var scroll_timer;