diff --git a/src/rules/replicateAttributes.ts b/src/rules/replicateAttributes.ts index 4fb7e99..7dc8924 100644 --- a/src/rules/replicateAttributes.ts +++ b/src/rules/replicateAttributes.ts @@ -61,6 +61,7 @@ export function integrifyReplicateAttributes( .onUpdate((change, context) => { const masterId = context.params.masterId; const newValue = change.after.data(); + const oldValue = change.before.data(); console.log( `integrify: Detected update in [${rule.source.collection}], id [${masterId}], new value:`, newValue @@ -77,7 +78,10 @@ export function integrifyReplicateAttributes( // Check if atleast one of the attributes to be replicated was changed let relevantUpdate = false; Object.keys(newValue).forEach((changedAttribute) => { - if (trackedMasterAttributes[changedAttribute]) { + if ( + trackedMasterAttributes[changedAttribute] && + newValue[changedAttribute] !== oldValue[changedAttribute] + ) { relevantUpdate = true; } });