Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

pointer: Stop sending bankruptcy pointer updates.

Tim Abbott8516dde8f4ef
diff --git a/static/js/panels.js b/static/js/panels.js
index 6d903363ac7..446bb78e094 100644
--- a/static/js/panels.js
+++ b/static/js/panels.js
@@ -94,7 +94,7 @@ exports.initialize = function () {
e.preventDefault();
$(this).closest(".alert").hide();
$('.bankruptcy-loader').show();
- setTimeout(pointer.fast_forward_pointer, 1000);
+ setTimeout(unread_ops.mark_all_as_read, 1000);
resize_app();
});
diff --git a/static/js/pointer.js b/static/js/pointer.js
index db588e4d14e..d055501bee7 100644
--- a/static/js/pointer.js
+++ b/static/js/pointer.js
@@ -51,37 +51,6 @@ exports.send_pointer_update = function () {
}
};
-function unconditionally_send_pointer_update() {
- if (pointer_update_in_flight) {
- // Keep trying.
- const deferred = $.Deferred();
-
- setTimeout(function () {
- deferred.resolve(unconditionally_send_pointer_update());
- }, 100);
- return deferred;
- }
- return update_pointer();
-}
-
-exports.fast_forward_pointer = function () {
- channel.get({
- url: '/json/users/me',
- idempotent: true,
- success: function (data) {
- unread_ops.mark_all_as_read(function () {
- exports.furthest_read = data.max_message_id;
- unconditionally_send_pointer_update().then(function () {
- reload.initiate({immediate: true,
- save_pointer: false,
- save_narrow: true,
- save_compose: true});
- });
- });
- },
- });
-};
-
exports.initialize = function initialize() {
exports.server_furthest_read = page_params.pointer;
exports.furthest_read = exports.server_furthest_read;
diff --git a/static/js/stream_popover.js b/static/js/stream_popover.js
index 598e43fc475..df2e52740d7 100644
--- a/static/js/stream_popover.js
+++ b/static/js/stream_popover.js
@@ -361,7 +361,7 @@ exports.register_stream_handlers = function () {
// Mark all messages as read
$('body').on('click', '#mark_all_messages_as_read', function (e) {
exports.hide_all_messages_popover();
- pointer.fast_forward_pointer();
+ unread_ops.mark_all_as_read();
e.stopPropagation();
});
diff --git a/static/js/unread_ops.js b/static/js/unread_ops.js
index a087f64073d..2babfb3f465 100644
--- a/static/js/unread_ops.js
+++ b/static/js/unread_ops.js
@@ -1,11 +1,19 @@
-exports.mark_all_as_read = function (cont) {
+exports.mark_all_as_read = function () {
unread.declare_bankruptcy();
unread_ui.update_unread_counts();
channel.post({
url: '/json/mark_all_as_read',
idempotent: true,
- success: cont});
+ success: () => {
+ // After marking all messages as read, we reload the browser.
+ // This is useful to avoid leaving ourselves deep in the past.
+ reload.initiate({immediate: true,
+ save_pointer: false,
+ save_narrow: true,
+ save_compose: true});
+ },
+ });
};
function process_newly_read_message(message, options) {