From 075257afb4d01642ed0a948b29db4e8f7fb872c4 Mon Sep 17 00:00:00 2001 From: Alejandro Hernandez Date: Thu, 25 Sep 2025 11:37:47 -0400 Subject: [PATCH 1/2] Call onUpdateByOthers on properties that have an 'all' reactor --- .changeset/wicked-ties-provide.md | 5 +++++ packages/client/src/index.js | 15 +++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 .changeset/wicked-ties-provide.md diff --git a/.changeset/wicked-ties-provide.md b/.changeset/wicked-ties-provide.md new file mode 100644 index 000000000..ddb7681b1 --- /dev/null +++ b/.changeset/wicked-ties-provide.md @@ -0,0 +1,5 @@ +--- +'contexture-client': minor +--- + +Call onUpdateByOthers on properties that have an 'all' reactor diff --git a/packages/client/src/index.js b/packages/client/src/index.js index 93f4244fc..b13baf3ba 100644 --- a/packages/client/src/index.js +++ b/packages/client/src/index.js @@ -134,14 +134,13 @@ export let ContextTree = _.curry( _.map(snapshot), _.find({ path: snapshot(event.path) }) )(updatedNodes) - if (!affectsSelf) - await Promise.all( - _.map((n) => { - // When updated by others, force replace instead of merge response - extend(n, { forceReplaceResponse: true }) - runTypeFunction(types, 'onUpdateByOthers', n, actionProps) - }, updatedNodes) - ) + await Promise.all( + _.map((n) => { + // When updated by others, force replace instead of merge response + extend(n, { forceReplaceResponse: true }) + runTypeFunction(types, 'onUpdateByOthers', n, actionProps) + }, _.remove({ path: snapshot(event.path) }, updatedNodes)) + ) // If disableAutoUpdate but this dispatch affects the target node, update *just* that node (to allow things like paging changes to always go through) // The assumption here is that any event that affects the target node would likely be assumed to take effect immediately by end users From c8679b57820968e242627d20f7be0deefdef7bc3 Mon Sep 17 00:00:00 2001 From: Alejandro Hernandez Date: Thu, 25 Sep 2025 12:32:04 -0400 Subject: [PATCH 2/2] Fix tests --- packages/client/src/index.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/client/src/index.js b/packages/client/src/index.js index b13baf3ba..24abee2f9 100644 --- a/packages/client/src/index.js +++ b/packages/client/src/index.js @@ -135,11 +135,17 @@ export let ContextTree = _.curry( _.find({ path: snapshot(event.path) }) )(updatedNodes) await Promise.all( - _.map((n) => { - // When updated by others, force replace instead of merge response - extend(n, { forceReplaceResponse: true }) - runTypeFunction(types, 'onUpdateByOthers', n, actionProps) - }, _.remove({ path: snapshot(event.path) }, updatedNodes)) + _.map( + (n) => { + // When updated by others, force replace instead of merge response + extend(n, { forceReplaceResponse: true }) + runTypeFunction(types, 'onUpdateByOthers', n, actionProps) + }, + _.remove( + (n) => _.isEqual(snapshot(n.path), snapshot(event.path)), + updatedNodes + ) + ) ) // If disableAutoUpdate but this dispatch affects the target node, update *just* that node (to allow things like paging changes to always go through)