File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -640,8 +640,6 @@ function keyChanged<TKey extends OnyxKey>(
640640 }
641641 }
642642
643- const cachedCollections : Record < string , ReturnType < typeof getCachedCollection > > = { } ;
644-
645643 for ( const stateMappingKey of stateMappingKeys ) {
646644 const subscriber = callbackToStateMapping [ stateMappingKey ] ;
647645 if ( ! subscriber || ! OnyxKeys . isKeyMatch ( subscriber . key , key ) || ! canUpdateSubscriber ( subscriber ) ) {
@@ -662,14 +660,9 @@ function keyChanged<TKey extends OnyxKey>(
662660 if ( isProcessingCollectionUpdate ) {
663661 continue ;
664662 }
665- let cachedCollection = cachedCollections [ subscriber . key ] ;
666-
667- if ( ! cachedCollection ) {
668- cachedCollection = getCachedCollection ( subscriber . key ) ;
669- cachedCollections [ subscriber . key ] = cachedCollection ;
670- }
671-
672- cachedCollection [ key ] = value ;
663+ // The cache is always updated before keyChanged runs (via broadcastUpdate → cache.set),
664+ // so the frozen snapshot already contains the new value — no patching needed.
665+ const cachedCollection = getCachedCollection ( subscriber . key ) ;
673666 lastConnectionCallbackData . set ( subscriber . subscriptionID , { value : cachedCollection , matchedKey : subscriber . key } ) ;
674667 subscriber . callback ( cachedCollection , subscriber . key , { [ key ] : value } ) ;
675668 continue ;
You can’t perform that action at this time.
0 commit comments