added changeId into entity_changes to have cross-sync change ID

This commit is contained in:
zadam
2021-11-18 22:33:08 +01:00
parent 15ac81627c
commit e36bc42519
6 changed files with 34 additions and 10 deletions

View File

@@ -149,10 +149,10 @@ async function pullChanges(syncContext) {
sql.transactional(() => {
for (const {entityChange, entity} of entityChanges) {
// FIXME: temporary fix
const existsAlready = !!sql.getValue("SELECT id FROM entity_changes WHERE entityName = ? AND entityId = ? AND utcDateChanged = ? AND hash = ?", [entityChange.entityName, entityChange.entityId, entityChange.utcDateChanged, entityChange.hash]);
const changeAppliedAlready = !entityChange.changeId
|| !!sql.getValue("SELECT id FROM entity_changes WHERE changeId = ?", [entityChange.changeId]);
if (!existsAlready && !sourceIdService.isLocalSourceId(entityChange.sourceId)) {
if (!changeAppliedAlready && !sourceIdService.isLocalSourceId(entityChange.sourceId)) {
if (!atLeastOnePullApplied) { // send only for first
ws.syncPullInProgress();