Skip to content

Commit b152564

Browse files
committed
Fix changes being emitted on deeply nested collections
1 parent 18e712e commit b152564

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

packages/db/src/query/live/collection-config-builder.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,7 +1779,7 @@ function flushIncludesState(
17791779
entry.collection,
17801780
entry.collection.id,
17811781
childChanges,
1782-
null,
1782+
entry.syncMethods,
17831783
)
17841784
}
17851785
}
@@ -1793,20 +1793,22 @@ function flushIncludesState(
17931793
entry.collection,
17941794
entry.collection.id,
17951795
null,
1796-
null,
1796+
entry.syncMethods,
17971797
)
17981798
}
17991799
}
18001800

18011801
// For toArray entries: re-emit affected parents with updated array snapshots
1802+
const toArrayReEmitKeys = state.materializeAsArray
1803+
? new Set([...(affectedCorrelationKeys || []), ...dirtyFromBuffers])
1804+
: null
18021805
if (
1803-
state.materializeAsArray &&
18041806
parentSyncMethods &&
1805-
affectedCorrelationKeys &&
1806-
affectedCorrelationKeys.size > 0
1807+
toArrayReEmitKeys &&
1808+
toArrayReEmitKeys.size > 0
18071809
) {
18081810
parentSyncMethods.begin()
1809-
for (const correlationKey of affectedCorrelationKeys) {
1811+
for (const correlationKey of toArrayReEmitKeys) {
18101812
const parentKeys = state.correlationToParentKeys.get(correlationKey)
18111813
if (!parentKeys) continue
18121814
const entry = state.childRegistry.get(correlationKey)

0 commit comments

Comments
 (0)