message_fetch: Select the anchor message in home view.

In the past, the anchor message has always been the same as the
pointer, but we're about to change that as part of removing the
pointer entirely.

Using the anchor is logically what we meant, anyway, since we always
want to select a message that's actually within the range we just
fetched.
This commit is contained in:
Tim Abbott 2020-02-19 13:45:57 -08:00 committed by Tim Abbott
parent 2beaf2cab2
commit fa25738159
2 changed files with 7 additions and 6 deletions

View File

@ -143,6 +143,7 @@ const initialize_data = {
resp: {
messages: message_range(201, 801),
found_newest: false,
anchor: 444,
},
},

View File

@ -340,13 +340,13 @@ exports.start_backfilling_messages = function () {
exports.initialize = function () {
// get the initial message list
function load_more(data) {
// If we received the initially selected message, select it on the client side,
// but not if the user has already selected another one during load.
//
// We fall back to the closest selected id, as the user may have removed
// a stream from the home before already
// If we haven't selected a message in the home view yet, and
// the home view isn't empty, we select the anchor message here.
if (home_msg_list.selected_id() === -1 && !home_msg_list.empty()) {
home_msg_list.select_id(page_params.pointer,
// We fall back to the closest selected id, as the user
// may have removed a stream from the home view while we
// were loading data.
home_msg_list.select_id(data.anchor,
{then_scroll: true, use_closest: true,
target_scroll_offset: page_params.initial_offset});
}