fix updating "lastAcceptedEntityId" - can't take last entityChange since they might be reordered based on update order, closes #2277

This commit is contained in:
zadam 2021-10-26 22:07:35 +02:00
parent 674172f0b8
commit e6af84df39

View file

@ -68,12 +68,13 @@ async function executeFrontendUpdate(entityChanges) {
frontendUpdateDataQueue.push(...entityChanges);
// we set lastAcceptedEntityChangeId even before frontend update processing and send ping so that backend can start sending more updates
lastAcceptedEntityChangeId = Math.max(lastAcceptedEntityChangeId, entityChanges[entityChanges.length - 1].id);
const lastSyncEntityChange = entityChanges.slice().reverse().find(ec => ec.isSynced);
for (const entityChange of entityChanges) {
lastAcceptedEntityChangeId = Math.max(lastAcceptedEntityChangeId, entityChange.id);
if (lastSyncEntityChange) {
lastAcceptedEntityChangeSyncId = Math.max(lastAcceptedEntityChangeSyncId, lastSyncEntityChange.id);
if (entityChange.isSynced) {
lastAcceptedEntityChangeSyncId = Math.max(lastAcceptedEntityChangeSyncId, entityChange.id);
}
}
sendPing();