pointer: Stop sending bankruptcy pointer updates.

Since the pointer is no longer used to set the browser's position, we
no longer need this complex code to send updates to the server during
the bankruptcy flow.
This commit is contained in:
Tim Abbott
2020-06-17 23:11:41 -07:00
committed by Tim Abbott
parent b840ec9491
commit 8516dde8f4
4 changed files with 12 additions and 35 deletions

View File

@@ -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();
});

View File

@@ -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;

View File

@@ -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();
});

View File

@@ -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) {