fix(react): deep merge models by namespace in entity updates#525
fix(react): deep merge models by namespace in entity updates#525MartianGreed merged 2 commits intomainfrom
Conversation
The mergeModels function was doing a shallow spread at the top level, which meant subscription updates for a single model (e.g. Order) would overwrite the entire namespace, losing sibling models (e.g. Game, Book). Now merges at the namespace level so only the updated models within a namespace are replaced while others are preserved. Fixes entity subscription updates not reflecting in derived atoms.
📝 WalkthroughWalkthroughThis PR fixes a shallow-merge bug in entity subscription updates by modifying the mergeModels function to perform namespace-scoped merging, preserving sibling models within namespaces when updating individual models. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
mergeModelsincreateEntityQueryWithUpdatesAtomandcreateEntitiesInfiniteScrollWithUpdatesAtomdoes a shallow spread:When a subscription update arrives for a single model (e.g.
ARCADE-Order), the parsed update produces{ ARCADE: { Order: {...} } }. The shallow spread replaces the entireARCADEnamespace, losing sibling models likeGame,Book, etc.This means derived atoms (like
listingsAtomin arcade) may not see updated entities because the merge destroys other model data on the same entity.Fix
Deep merge at the namespace level:
Only the specific models within a namespace get replaced; siblings are preserved.
Summary by CodeRabbit
Bug Fixes