From 0bc272fc861943af422924199ca5135afa3f2609 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Mon, 28 May 2018 22:21:13 +0000 Subject: [PATCH] hotkeys: Fix very recent regression with down key. In 1f72647a5abad06513fcd178c58c1d038c65fa20 I accidentally flipped a condition that made the down key "recenter" on the "normal" case, not in the "is-at-end" case. This commit undoes that regression, which probably only affected czo for a weekend, and makes the logic a bit more clear. --- static/js/navigate.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/static/js/navigate.js b/static/js/navigate.js index a9459aa16a..10ab21e082 100644 --- a/static/js/navigate.js +++ b/static/js/navigate.js @@ -20,23 +20,26 @@ exports.up = function () { exports.down = function (with_centering) { message_viewport.last_movement_direction = 1; + + if (current_msg_list.is_at_end()) { + if (with_centering) { + // At the last message, scroll to the bottom so we have + // lots of nice whitespace for new messages coming in. + var current_msg_table = rows.get_table(current_msg_list.table_name); + message_viewport.scrollTop(current_msg_table.safeOuterHeight(true) - + message_viewport.height() * 0.1); + unread_ops.mark_current_list_as_read(); + } + + return; + } + + // Normal path starts here. var msg_id = current_msg_list.next(); if (msg_id === undefined) { return; } go_to_row(msg_id); - - if (with_centering) { - // At the last message, scroll to the bottom so we have - // lots of nice whitespace for new messages coming in. - // - // FIXME: this doesn't work for End because rows.last_visible() - // always returns a message. - var current_msg_table = rows.get_table(current_msg_list.table_name); - message_viewport.scrollTop(current_msg_table.safeOuterHeight(true) - - message_viewport.height() * 0.1); - unread_ops.mark_current_list_as_read(); - } }; exports.to_home = function () {