mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
Improve processing for get_updates during tutorial.
Previously, we would slowly accumulate duplicate copies of events that happened while the user was in the tutorial at a rate of 1 copy per 5 seconds. (imported from commit 3e3c58aca4b1ba3bfdd1c93f47330a0f4cf4b60f)
This commit is contained in:
@@ -784,6 +784,11 @@ function get_updates_success(data) {
|
|||||||
var messages_to_update = [];
|
var messages_to_update = [];
|
||||||
var new_pointer;
|
var new_pointer;
|
||||||
|
|
||||||
|
_.each(data.events, function (event) {
|
||||||
|
get_updates_params.last_event_id = Math.max(get_updates_params.last_event_id,
|
||||||
|
event.id);
|
||||||
|
});
|
||||||
|
|
||||||
if (tutorial.is_running()) {
|
if (tutorial.is_running()) {
|
||||||
events_stored_during_tutorial = events_stored_during_tutorial.concat(data.events);
|
events_stored_during_tutorial = events_stored_during_tutorial.concat(data.events);
|
||||||
return;
|
return;
|
||||||
@@ -795,9 +800,6 @@ function get_updates_success(data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_.each(data.events, function (event) {
|
_.each(data.events, function (event) {
|
||||||
get_updates_params.last_event_id = Math.max(get_updates_params.last_event_id,
|
|
||||||
event.id);
|
|
||||||
|
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case 'message':
|
case 'message':
|
||||||
var msg = event.message;
|
var msg = event.message;
|
||||||
@@ -993,12 +995,7 @@ function get_updates(options) {
|
|||||||
$('#connection-error').hide();
|
$('#connection-error').hide();
|
||||||
|
|
||||||
get_updates_success(data);
|
get_updates_success(data);
|
||||||
|
get_updates_timeout = setTimeout(get_updates, 0);
|
||||||
if (tutorial.is_running()) {
|
|
||||||
get_updates_timeout = setTimeout(get_updates, 5000);
|
|
||||||
} else {
|
|
||||||
get_updates_timeout = setTimeout(get_updates, 0);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
error: function (xhr, error_type, exn) {
|
error: function (xhr, error_type, exn) {
|
||||||
get_updates_xhr = undefined;
|
get_updates_xhr = undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user