Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions lib/OnyxUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -899,10 +899,6 @@ function remove<TKey extends OnyxKey>(key: TKey, isProcessingCollectionUpdate?:
cache.drop(key);
scheduleSubscriberUpdate(key, undefined as OnyxValue<TKey>, undefined, isProcessingCollectionUpdate);

if (isRamOnlyKey(key)) {
return Promise.resolve();
}

return Storage.removeItem(key).then(() => undefined);
}

Expand Down
16 changes: 16 additions & 0 deletions tests/unit/onyxUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,22 @@ describe('OnyxUtils', () => {
});
});

describe('remove', () => {
it('should remove RAM-only key from storage when set to null', async () => {
const removeItemSpy = jest.spyOn(StorageMock, 'removeItem');

// First set the RAM-only key to a value
await Onyx.set(ONYXKEYS.RAM_ONLY_KEY, 'testValue');

removeItemSpy.mockClear();

// Setting null should trigger OnyxUtils.remove, which should also remove from storage
await Onyx.set(ONYXKEYS.RAM_ONLY_KEY, null);

expect(removeItemSpy).toHaveBeenCalledWith(ONYXKEYS.RAM_ONLY_KEY);
});
});

describe('isRamOnlyKey', () => {
it('should return true for RAM-only key', () => {
expect(OnyxUtils.isRamOnlyKey(ONYXKEYS.RAM_ONLY_KEY)).toBeTruthy();
Expand Down