Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
pointer: Remove frontend logic tracking furthest_read.
Tim Abbott94e6cb9abda0
diff --git a/frontend_tests/node_tests/server_events.js b/frontend_tests/node_tests/server_events.jsindex b8cc7f56c45..e14634912c5 100644--- a/frontend_tests/node_tests/server_events.js+++ b/frontend_tests/node_tests/server_events.js@@ -56,25 +56,6 @@ run_test('message_event', () => {assert(inserted);});-run_test('pointer_event', () => {- const event = {- type: 'pointer',- pointer: 999,- };-- global.pointer.furthest_read = 0;- global.pointer.set_furthest_read = function (value) {- 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);-});-// Start blueslip tests hereconst setup = function () {diff --git a/static/js/message_store.js b/static/js/message_store.jsindex 3cebaa1e1c4..01a83d10eae 100644--- a/static/js/message_store.js+++ b/static/js/message_store.js@@ -208,9 +208,6 @@ exports.add_message_metadata = function (message) {exports.reify_message_id = function (opts) {const old_id = opts.old_id;const new_id = opts.new_id;- if (pointer.furthest_read === old_id) {- pointer.set_furthest_read(new_id);- }if (stored_messages.has(old_id)) {stored_messages.set(new_id, stored_messages.get(old_id));stored_messages.delete(old_id);diff --git a/static/js/pointer.js b/static/js/pointer.jsindex d055501bee7..c40be3a6887 100644--- a/static/js/pointer.js+++ b/static/js/pointer.js@@ -12,70 +12,12 @@ exports.suppress_scroll_pointer_update = false;exports.set_suppress_scroll_pointer_update = function (value) {exports.suppress_scroll_pointer_update = value;};-exports.furthest_read = -1;-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;-};--let pointer_update_in_flight = false;--function update_pointer() {- if (!pointer_update_in_flight) {- pointer_update_in_flight = true;- return channel.post({- url: '/json/users/me/pointer',- idempotent: true,- data: {pointer: exports.furthest_read},- success: function () {- exports.server_furthest_read = exports.furthest_read;- pointer_update_in_flight = false;- },- error: function () {- pointer_update_in_flight = false;- },- });- }- // Return an empty, resolved Deferred.- return $.when();-}---exports.send_pointer_update = function () {- // Only bother if you've read new messages.- if (exports.furthest_read > exports.server_furthest_read) {- update_pointer();- }-};exports.initialize = function initialize() {- exports.server_furthest_read = page_params.pointer;- exports.furthest_read = exports.server_furthest_read;-- // We only send pointer updates when the user has been idle for a- // short while to avoid hammering the server- $(document).idle({idle: 1000,- onIdle: exports.send_pointer_update,- keepTracking: true});-$(document).on('message_selected.zulip', function (event) {- // Only advance the pointer when not narrowedif (event.id === -1) {return;}- // Additionally, don't advance the pointer server-side- // if the selected message is local-only- if (event.msg_list === home_msg_list && page_params.narrow_stream === undefined) {- if (event.id > exports.furthest_read) {- const msg = home_msg_list.get(event.id);- if (!msg.locally_echoed) {- exports.furthest_read = event.id;- }- }- }if (event.mark_read && event.previously_selected !== -1) {// Mark messages between old pointer and new pointer as readdiff --git a/static/js/server_events.js b/static/js/server_events.jsindex 47756a2d8fb..a62598960a8 100644--- a/static/js/server_events.js+++ b/static/js/server_events.js@@ -19,7 +19,6 @@ function get_events_success(events) {let messages = [];const update_message_events = [];const post_message_events = [];- let new_pointer;const clean_event = function clean_event(event) {// Only log a whitelist of the event to remove private data@@ -64,10 +63,6 @@ function get_events_success(events) {break;}- case 'pointer':- new_pointer = event.pointer;- break;-case 'update_message':update_message_events.push(event);break;@@ -125,13 +120,6 @@ function get_events_success(events) {}}- if (new_pointer !== undefined- && new_pointer > pointer.furthest_read) {- pointer.set_furthest_read(new_pointer);- pointer.set_server_furthest_read(new_pointer);- home_msg_list.select_id(new_pointer, {then_scroll: true, use_closest: true});- }-if (home_msg_list.selected_id() === -1 && !home_msg_list.empty()) {home_msg_list.select_id(home_msg_list.first().id, {then_scroll: false});}