diff --git a/lib/OnyxUtils.ts b/lib/OnyxUtils.ts index 446e7bd2..fe27ddf5 100644 --- a/lib/OnyxUtils.ts +++ b/lib/OnyxUtils.ts @@ -899,10 +899,6 @@ function remove(key: TKey, isProcessingCollectionUpdate?: cache.drop(key); scheduleSubscriberUpdate(key, undefined as OnyxValue, undefined, isProcessingCollectionUpdate); - if (isRamOnlyKey(key)) { - return Promise.resolve(); - } - return Storage.removeItem(key).then(() => undefined); } diff --git a/tests/unit/onyxUtilsTest.ts b/tests/unit/onyxUtilsTest.ts index 3448c6ad..6a4cdb26 100644 --- a/tests/unit/onyxUtilsTest.ts +++ b/tests/unit/onyxUtilsTest.ts @@ -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();