pointer.js: Add setter for server_furthest_read.

After migration to an ES6 module, `server_furthest_read` would no
longer be mutable from outside the module.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg 2018-08-04 02:41:12 -04:00 committed by Tim Abbott
parent e559662c8c
commit f9bf414b58
3 changed files with 7 additions and 1 deletions

View File

@ -71,6 +71,9 @@ run_test('pointer_event', () => {
this.furthest_read = value; this.furthest_read = value;
}; };
global.pointer.server_furthest_read = 0; global.pointer.server_furthest_read = 0;
global.pointer.set_server_furthest_read = function (value) {
this.server_furthest_read = value;
};
server_events._get_events_success([event]); server_events._get_events_success([event]);
assert.equal(global.pointer.furthest_read, event.pointer); assert.equal(global.pointer.furthest_read, event.pointer);
assert.equal(global.pointer.server_furthest_read, event.pointer); assert.equal(global.pointer.server_furthest_read, event.pointer);

View File

@ -18,6 +18,9 @@ exports.set_furthest_read = function (value) {
exports.furthest_read = value; exports.furthest_read = value;
}; };
exports.server_furthest_read = -1; exports.server_furthest_read = -1;
exports.set_server_furthest_read = function (value) {
exports.server_furthest_read = value;
};
var pointer_update_in_flight = false; var pointer_update_in_flight = false;

View File

@ -134,7 +134,7 @@ function get_events_success(events) {
if (new_pointer !== undefined if (new_pointer !== undefined
&& new_pointer > pointer.furthest_read) { && new_pointer > pointer.furthest_read) {
pointer.set_furthest_read(new_pointer); pointer.set_furthest_read(new_pointer);
pointer.server_furthest_read = new_pointer; pointer.set_server_furthest_read(new_pointer);
home_msg_list.select_id(new_pointer, {then_scroll: true, use_closest: true}); home_msg_list.select_id(new_pointer, {then_scroll: true, use_closest: true});
} }