From f9bf414b5835859bb8090e47e54a090587a52ef0 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Sat, 4 Aug 2018 02:41:12 -0400 Subject: [PATCH] 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 --- frontend_tests/node_tests/server_events.js | 3 +++ static/js/pointer.js | 3 +++ static/js/server_events.js | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend_tests/node_tests/server_events.js b/frontend_tests/node_tests/server_events.js index 9e241bf6e6..dd90adf936 100644 --- a/frontend_tests/node_tests/server_events.js +++ b/frontend_tests/node_tests/server_events.js @@ -71,6 +71,9 @@ run_test('pointer_event', () => { this.furthest_read = value; }; 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]); assert.equal(global.pointer.furthest_read, event.pointer); assert.equal(global.pointer.server_furthest_read, event.pointer); diff --git a/static/js/pointer.js b/static/js/pointer.js index b95a34ea39..a72aa90bc9 100644 --- a/static/js/pointer.js +++ b/static/js/pointer.js @@ -18,6 +18,9 @@ exports.set_furthest_read = function (value) { exports.furthest_read = value; }; exports.server_furthest_read = -1; +exports.set_server_furthest_read = function (value) { + exports.server_furthest_read = value; +}; var pointer_update_in_flight = false; diff --git a/static/js/server_events.js b/static/js/server_events.js index 0b00b72797..f7b7ba7837 100644 --- a/static/js/server_events.js +++ b/static/js/server_events.js @@ -134,7 +134,7 @@ function get_events_success(events) { if (new_pointer !== undefined && new_pointer > pointer.furthest_read) { 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}); }