mirror of
https://github.com/zadam/trilium.git
synced 2024-11-10 17:13:45 +08:00
fix updating "lastAcceptedEntityId" - can't take last entityChange since they might be reordered based on update order, closes #2277
This commit is contained in:
parent
674172f0b8
commit
e6af84df39
1 changed files with 5 additions and 4 deletions
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue