mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 07:23:22 +00:00
Make bankrupting more resilient against regular pointer updates being in flight.
(imported from commit 90e1dc16e7d3295b6ed3f5993fe82ac4fcd2d7cc)
This commit is contained in:
@@ -412,11 +412,10 @@ function mark_read_between(msg_list, start_id, end_id) {
|
|||||||
process_read_messages(mark_as_read);
|
process_read_messages(mark_as_read);
|
||||||
}
|
}
|
||||||
|
|
||||||
function send_pointer_update() {
|
function update_pointer() {
|
||||||
if (!pointer_update_in_flight &&
|
if (!pointer_update_in_flight) {
|
||||||
furthest_read > server_furthest_read) {
|
|
||||||
pointer_update_in_flight = true;
|
pointer_update_in_flight = true;
|
||||||
$.ajax({
|
return $.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: '/json/update_pointer',
|
url: '/json/update_pointer',
|
||||||
data: {pointer: furthest_read},
|
data: {pointer: furthest_read},
|
||||||
@@ -429,6 +428,25 @@ function send_pointer_update() {
|
|||||||
pointer_update_in_flight = false;
|
pointer_update_in_flight = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
// Return an empty, resolved Deferred.
|
||||||
|
return $.when();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function send_pointer_update() {
|
||||||
|
// Only bother if you've read new messages.
|
||||||
|
if (furthest_read > server_furthest_read) {
|
||||||
|
update_pointer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function unconditionally_send_pointer_update() {
|
||||||
|
if (pointer_update_in_flight) {
|
||||||
|
// Keep trying.
|
||||||
|
return unconditionally_send_pointer_update();
|
||||||
|
} else {
|
||||||
|
return update_pointer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1214,10 +1232,11 @@ function fast_forward_pointer() {
|
|||||||
success: function (data) {
|
success: function (data) {
|
||||||
mark_all_as_read(function () {
|
mark_all_as_read(function () {
|
||||||
furthest_read = data.max_message_id;
|
furthest_read = data.max_message_id;
|
||||||
send_pointer_update();
|
unconditionally_send_pointer_update().then(function () {
|
||||||
ui.change_tab_to('#home');
|
ui.change_tab_to('#home');
|
||||||
reload.initiate({immediate: true});
|
reload.initiate({immediate: true});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user