mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
sync fixes and refactorings
This commit is contained in:
parent
e8b52f9e6c
commit
12014b9f4d
@ -12,7 +12,7 @@ let maxEntityChangeId = 0;
|
|||||||
function putEntityChangeWithInstanceId(origEntityChange, instanceId) {
|
function putEntityChangeWithInstanceId(origEntityChange, instanceId) {
|
||||||
const ec = {...origEntityChange, instanceId};
|
const ec = {...origEntityChange, instanceId};
|
||||||
|
|
||||||
return putEntityChange(ec);
|
putEntityChange(ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
function putEntityChange(origEntityChange) {
|
function putEntityChange(origEntityChange) {
|
||||||
@ -56,7 +56,11 @@ function putNoteReorderingEntityChange(parentNoteId, componentId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function putEntityChangeForOtherInstances(ec) {
|
function putEntityChangeForOtherInstances(ec) {
|
||||||
putEntityChangeWithInstanceId(ec, null);
|
putEntityChange({
|
||||||
|
...ec,
|
||||||
|
changeId: null,
|
||||||
|
instanceId: null
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function addEntityChangesForSector(entityName, sector) {
|
function addEntityChangesForSector(entityName, sector) {
|
||||||
|
@ -146,9 +146,12 @@ async function pullChanges(syncContext) {
|
|||||||
sql.transactional(() => {
|
sql.transactional(() => {
|
||||||
for (const {entityChange, entity} of entityChanges) {
|
for (const {entityChange, entity} of entityChanges) {
|
||||||
const changeAppliedAlready = entityChange.changeId
|
const changeAppliedAlready = entityChange.changeId
|
||||||
&& !!sql.getValue("SELECT id FROM entity_changes WHERE changeId = ?", [entityChange.changeId]);
|
&& !!sql.getValue("SELECT 1 FROM entity_changes WHERE changeId = ?", [entityChange.changeId]);
|
||||||
|
|
||||||
|
if (changeAppliedAlready) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!changeAppliedAlready) {
|
|
||||||
if (!atLeastOnePullApplied) { // send only for first
|
if (!atLeastOnePullApplied) { // send only for first
|
||||||
ws.syncPullInProgress();
|
ws.syncPullInProgress();
|
||||||
|
|
||||||
@ -157,7 +160,6 @@ async function pullChanges(syncContext) {
|
|||||||
|
|
||||||
syncUpdateService.updateEntity(entityChange, entity, syncContext.instanceId);
|
syncUpdateService.updateEntity(entityChange, entity, syncContext.instanceId);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (lastSyncedPull !== lastEntityChangeId) {
|
if (lastSyncedPull !== lastEntityChangeId) {
|
||||||
setLastSyncedPull(lastEntityChangeId);
|
setLastSyncedPull(lastEntityChangeId);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user