From df0e4a73fa4fdc8d5f443b21c983870287c7ce28 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Thu, 3 May 2018 10:44:38 +0000 Subject: [PATCH] refactor: Remove brittle check for !select_first_unread. When we are deciding whether to preserve scroll position, we mainly care that then_select_offset is set to a value. If we had no intention of preserving scroll offset, we would have never bothered to set it. The check for !select_first_unread is always redundant, as verified by lots of clicking around with some print debugging. And it's a brittle check, because it couples the decision of scrolling destination to the mechanism by which we decide our selection. While those things are closely related, it's possible in the future that we'll decide to advance to an unread message and still want to set then_select_offset, but we might forget to mutate select_first_unread. Long story short, the code is simpler and safer now. --- static/js/narrow.js | 1 - 1 file changed, 1 deletion(-) diff --git a/static/js/narrow.js b/static/js/narrow.js index 706a6a563a..3175ce0690 100644 --- a/static/js/narrow.js +++ b/static/js/narrow.js @@ -168,7 +168,6 @@ exports.activate = function (raw_operators, opts) { } var preserve_pre_narrowing_screen_position = - !select_first_unread && (message_list.narrowed.get(then_select_id) !== undefined) && (then_select_offset !== undefined);