Skip to content

Commit 8e3e906

Browse files
committed
Address comments
1 parent 1351565 commit 8e3e906

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

lib/OnyxKeys.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,7 @@ function setRamOnlyKeys(keys: Set<OnyxKey>): void {
210210
* - isRamOnlyKey("someOtherKey") → false
211211
*/
212212
function isRamOnlyKey(key: OnyxKey): boolean {
213-
const collectionKey = getCollectionKey(key);
214-
if (collectionKey) {
215-
return ramOnlyKeySet.has(collectionKey);
216-
}
217-
return ramOnlyKeySet.has(key);
213+
return ramOnlyKeySet.has(key) || ramOnlyKeySet.has(getCollectionKey(key) ?? '');
218214
}
219215

220216
export default {

tests/unit/OnyxKeysTest.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,20 @@ describe('OnyxKeys', () => {
2828
describe('splitCollectionMemberKey', () => {
2929
describe('should return correct values', () => {
3030
const dataResult: Record<string, [string, string]> = {
31+
// Collection key with no member ID
3132
test_: ['test_', ''],
33+
// Nested collection key with no member ID
3234
test_level_: ['test_level_', ''],
35+
// Nested collection keys with member IDs
3336
test_level_1: ['test_level_', '1'],
3437
test_level_2: ['test_level_', '2'],
38+
// Deeply nested collection member key, matches longest prefix
3539
test_level_last_3: ['test_level_last_', '3'],
40+
// Underscores in the ID portion, only the first matching prefix is the collection key
3641
test___FAKE__: ['test_', '__FAKE__'],
42+
// Negative/compound IDs, the collection is 'test_', everything after is the ID
3743
'test_-1_something': ['test_', '-1_something'],
44+
// Nested collection with compound ID, 'test_level_' is the longest matching collection
3845
'test_level_-1_something': ['test_level_', '-1_something'],
3946
};
4047

0 commit comments

Comments
 (0)