diff --git a/frontend_tests/node_tests/message_store.js b/frontend_tests/node_tests/message_store.js index 43fc237fd3..3846267d80 100644 --- a/frontend_tests/node_tests/message_store.js +++ b/frontend_tests/node_tests/message_store.js @@ -203,6 +203,7 @@ run_test('message_id_change', () => { set_global('pointer', { furthest_read: 401, + set_furthest_read: function (value) { this.furthest_read = value; }, }); set_global('message_list', {}); diff --git a/frontend_tests/node_tests/server_events.js b/frontend_tests/node_tests/server_events.js index f635ae994e..9e241bf6e6 100644 --- a/frontend_tests/node_tests/server_events.js +++ b/frontend_tests/node_tests/server_events.js @@ -67,6 +67,9 @@ run_test('pointer_event', () => { }; global.pointer.furthest_read = 0; + global.pointer.set_furthest_read = function (value) { + this.furthest_read = value; + }; global.pointer.server_furthest_read = 0; server_events._get_events_success([event]); assert.equal(global.pointer.furthest_read, event.pointer); diff --git a/static/js/message_store.js b/static/js/message_store.js index 426e9082d6..ed3300cec7 100644 --- a/static/js/message_store.js +++ b/static/js/message_store.js @@ -176,7 +176,7 @@ exports.reify_message_id = function (opts) { var old_id = opts.old_id; var new_id = opts.new_id; if (pointer.furthest_read === old_id) { - pointer.furthest_read = new_id; + pointer.set_furthest_read(new_id); } if (stored_messages[old_id]) { stored_messages[new_id] = stored_messages[old_id]; diff --git a/static/js/pointer.js b/static/js/pointer.js index 050a281172..dd354dad75 100644 --- a/static/js/pointer.js +++ b/static/js/pointer.js @@ -11,6 +11,9 @@ exports.recenter_pointer_on_display = false; // when All Messages is next clicked by the user exports.suppress_scroll_pointer_update = false; exports.furthest_read = -1; +exports.set_furthest_read = function (value) { + exports.furthest_read = value; +}; exports.server_furthest_read = -1; var pointer_update_in_flight = false; diff --git a/static/js/server_events.js b/static/js/server_events.js index 7ead05dc4e..0b00b72797 100644 --- a/static/js/server_events.js +++ b/static/js/server_events.js @@ -133,7 +133,7 @@ function get_events_success(events) { if (new_pointer !== undefined && new_pointer > pointer.furthest_read) { - pointer.furthest_read = new_pointer; + pointer.set_furthest_read(new_pointer); pointer.server_furthest_read = new_pointer; home_msg_list.select_id(new_pointer, {then_scroll: true, use_closest: true}); }