From 2f237f9f1a15f36fd33f10cfb9ca4f4f0e446ae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Miko=C5=82ajczak?= Date: Mon, 5 Aug 2024 22:24:28 +0200 Subject: [PATCH] fix getCachedCollection caching --- lib/OnyxUtils.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/OnyxUtils.ts b/lib/OnyxUtils.ts index 528b335b..45961dee 100644 --- a/lib/OnyxUtils.ts +++ b/lib/OnyxUtils.ts @@ -823,7 +823,12 @@ function keyChanged( } if (isCollectionKey(subscriber.key) && subscriber.waitForCollectionCallback) { - const cachedCollection = cachedCollections[subscriber.key] ?? getCachedCollection(subscriber.key); + let cachedCollection = cachedCollections[subscriber.key]; + + if (!cachedCollection) { + cachedCollection = getCachedCollection(subscriber.key); + cachedCollections[subscriber.key] = cachedCollection; + } cachedCollection[key] = value; subscriber.callback(cachedCollection);