pointer: Remove orig_initial_pointer hackery.

The orig_initial_pointer variable was part of the implementation for
ensuring server-initiated reloads preserve the user's selected message
and scroll position (so that they are not disruptive).  Previously,
the logic did some unnecessary contortions to ensure the two goals:

* The `pointer.js` logic knows what the server thinks the pointer is.
* The `message_fetch.js` logic knows what anchor to use to center it's
  home view fetch.

It's a lot cleaner to do this by not mutating page_params.pointer.
This commit is contained in:
Tim Abbott
2020-02-19 13:24:00 -08:00
committed by Tim Abbott
parent fa25738159
commit 961100024e
3 changed files with 10 additions and 7 deletions

View File

@@ -374,8 +374,16 @@ exports.initialize = function () {
}
let anchor;
if (page_params.initial_pointer) {
// If we're doing a server-initiated reload, similar to a
// near: narrow query, we want to select a specific message.
anchor = page_params.initial_pointer;
} else {
anchor = page_params.pointer;
}
exports.load_messages({
anchor: page_params.pointer,
anchor: anchor,
num_before: consts.num_before_pointer,
num_after: consts.num_after_pointer,
msg_list: home_msg_list,

View File

@@ -84,10 +84,6 @@ exports.fast_forward_pointer = function () {
exports.initialize = function initialize() {
exports.server_furthest_read = page_params.pointer;
if (page_params.orig_initial_pointer !== undefined &&
page_params.orig_initial_pointer > exports.server_furthest_read) {
exports.server_furthest_read = page_params.orig_initial_pointer;
}
exports.furthest_read = exports.server_furthest_read;
// We only send pointer updates when the user has been idle for a

View File

@@ -148,8 +148,7 @@ exports.initialize = function () {
const pointer = parseInt(vars.pointer, 10);
if (pointer) {
page_params.orig_initial_pointer = page_params.pointer;
page_params.pointer = pointer;
page_params.initial_pointer = pointer;
}
const offset = parseInt(vars.offset, 10);
if (offset) {