Skip to content

Commit fb4b1c0

Browse files
committed
fix: send collection key as matchedKey when we have a collection callbcak
1 parent 2ae6062 commit fb4b1c0

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

lib/OnyxUtils.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ function addKeyToRecentlyAccessedIfNeeded<TKey extends OnyxKey>(key: TKey): void
847847
function getCollectionDataAndSendAsObject<TKey extends OnyxKey>(matchingKeys: CollectionKeyBase[], mapping: CallbackToStateMapping<TKey>): void {
848848
multiGet(matchingKeys).then((dataMap) => {
849849
const data = Object.fromEntries(dataMap.entries()) as OnyxValue<TKey>;
850-
sendDataToConnection(mapping, data, undefined);
850+
sendDataToConnection(mapping, data, mapping.key);
851851
});
852852
}
853853

@@ -1173,9 +1173,12 @@ function subscribeToKey<TKey extends OnyxKey>(connectOptions: ConnectOptions<TKe
11731173
cache.addNullishStorageKey(mapping.key);
11741174
}
11751175

1176+
const shouldSendCollectionKey = isCollectionKey(mapping.key) && mapping.waitForCollectionCallback;
1177+
const matchedKey = shouldSendCollectionKey ? mapping.key : undefined;
1178+
11761179
// Here we cannot use batching because the nullish value is expected to be set immediately for default props
11771180
// or they will be undefined.
1178-
sendDataToConnection(mapping, null, undefined);
1181+
sendDataToConnection(mapping, null, matchedKey);
11791182
return;
11801183
}
11811184

0 commit comments

Comments
 (0)