Skip to content

Commit 65948a8

Browse files
committed
Fix changes being emitted on deeply nested collections
1 parent 4e0f9ad commit 65948a8

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
@@ -1776,7 +1776,7 @@ function flushIncludesState(
17761776
entry.collection,
17771777
entry.collection.id,
17781778
childChanges,
1779-
null,
1779+
entry.syncMethods,
17801780
)
17811781
}
17821782
}
@@ -1790,20 +1790,22 @@ function flushIncludesState(
17901790
entry.collection,
17911791
entry.collection.id,
17921792
null,
1793-
null,
1793+
entry.syncMethods,
17941794
)
17951795
}
17961796
}
17971797

17981798
// For toArray entries: re-emit affected parents with updated array snapshots
1799+
const toArrayReEmitKeys = state.materializeAsArray
1800+
? new Set([...(affectedCorrelationKeys || []), ...dirtyFromBuffers])
1801+
: null
17991802
if (
1800-
state.materializeAsArray &&
18011803
parentSyncMethods &&
1802-
affectedCorrelationKeys &&
1803-
affectedCorrelationKeys.size > 0
1804+
toArrayReEmitKeys &&
1805+
toArrayReEmitKeys.size > 0
18041806
) {
18051807
parentSyncMethods.begin()
1806-
for (const correlationKey of affectedCorrelationKeys) {
1808+
for (const correlationKey of toArrayReEmitKeys) {
18071809
const parentKeys = state.correlationToParentKeys.get(correlationKey)
18081810
if (!parentKeys) continue
18091811
const entry = state.childRegistry.get(correlationKey)

0 commit comments

Comments
 (0)