From ca7ca24f62caa85e2466bba2513f6cc7971d4a7e Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Tue, 1 Aug 2023 17:29:17 +0300 Subject: [PATCH] Revert Onyx direct cache access --- package-lock.json | 14 +++++++------- package.json | 2 +- src/libs/actions/QueuedOnyxUpdates.js | 2 +- tests/unit/EmojiTest.js | 6 +++--- tests/unit/SidebarOrderTest.js | 3 ++- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 48c4befc96be..0668971be2a4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -79,7 +79,7 @@ "react-native-key-command": "^1.0.1", "react-native-localize": "^2.2.6", "react-native-modal": "^13.0.0", - "react-native-onyx": "1.0.56", + "react-native-onyx": "1.0.52", "react-native-pdf": "^6.6.2", "react-native-performance": "^4.0.0", "react-native-permissions": "^3.0.1", @@ -36561,9 +36561,9 @@ } }, "node_modules/react-native-onyx": { - "version": "1.0.56", - "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-1.0.56.tgz", - "integrity": "sha512-6KHwCwCgTtgZ2gGgCFxbJRRL4e2tamCjdbb9ca0jDCUgxZ6NQkEkVhZLaFCPwQn1dX7zonbdbaciFjlUxyOVFQ==", + "version": "1.0.52", + "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-1.0.52.tgz", + "integrity": "sha512-lfIg+tSd+HZF00pr2oFoLY3iTdGYGC6Dd44/YktTsVKB/yIcUq61wBMOitX54Z54ac2/eHKFPicEr2xvBhE2VQ==", "dependencies": { "ascii-table": "0.0.9", "fast-equals": "^4.0.3", @@ -68164,9 +68164,9 @@ } }, "react-native-onyx": { - "version": "1.0.56", - "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-1.0.56.tgz", - "integrity": "sha512-6KHwCwCgTtgZ2gGgCFxbJRRL4e2tamCjdbb9ca0jDCUgxZ6NQkEkVhZLaFCPwQn1dX7zonbdbaciFjlUxyOVFQ==", + "version": "1.0.52", + "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-1.0.52.tgz", + "integrity": "sha512-lfIg+tSd+HZF00pr2oFoLY3iTdGYGC6Dd44/YktTsVKB/yIcUq61wBMOitX54Z54ac2/eHKFPicEr2xvBhE2VQ==", "requires": { "ascii-table": "0.0.9", "fast-equals": "^4.0.3", diff --git a/package.json b/package.json index 772b441667dc..59a3ecb905c6 100644 --- a/package.json +++ b/package.json @@ -117,7 +117,7 @@ "react-native-key-command": "^1.0.1", "react-native-localize": "^2.2.6", "react-native-modal": "^13.0.0", - "react-native-onyx": "1.0.56", + "react-native-onyx": "1.0.52", "react-native-pdf": "^6.6.2", "react-native-performance": "^4.0.0", "react-native-permissions": "^3.0.1", diff --git a/src/libs/actions/QueuedOnyxUpdates.js b/src/libs/actions/QueuedOnyxUpdates.js index 486108dd56cf..d25f44a9aa60 100644 --- a/src/libs/actions/QueuedOnyxUpdates.js +++ b/src/libs/actions/QueuedOnyxUpdates.js @@ -14,7 +14,7 @@ Onyx.connect({ * @returns {Promise} */ function queueOnyxUpdates(updates) { - return Onyx.set(ONYXKEYS.QUEUED_ONYX_UPDATES, [...queuedOnyxUpdates, ...updates]); + return Onyx.merge(ONYXKEYS.QUEUED_ONYX_UPDATES, updates); } function clear() { diff --git a/tests/unit/EmojiTest.js b/tests/unit/EmojiTest.js index 69f38fa349af..0e9b7a7c8c0f 100644 --- a/tests/unit/EmojiTest.js +++ b/tests/unit/EmojiTest.js @@ -203,7 +203,7 @@ describe('EmojiTest', () => { lastUpdatedAt: 1, }, ]; - Onyx.set(ONYXKEYS.FREQUENTLY_USED_EMOJIS, frequentlyEmojisList); + Onyx.merge(ONYXKEYS.FREQUENTLY_USED_EMOJIS, frequentlyEmojisList); return waitForPromisesToResolve().then(() => { // When add a new emoji @@ -293,7 +293,7 @@ describe('EmojiTest', () => { }, {...smileEmoji, count: 1, lastUpdatedAt: 1}, ]; - Onyx.set(ONYXKEYS.FREQUENTLY_USED_EMOJIS, frequentlyEmojisList); + Onyx.merge(ONYXKEYS.FREQUENTLY_USED_EMOJIS, frequentlyEmojisList); return waitForPromisesToResolve().then(() => { // When add multiple emojis that either exist or not exist in the list @@ -464,7 +464,7 @@ describe('EmojiTest', () => { {...bookEmoji, count: 3, lastUpdatedAt: 1}, ]; expect(frequentlyEmojisList.length).toBe(CONST.EMOJI_FREQUENT_ROW_COUNT * CONST.EMOJI_NUM_PER_ROW); - Onyx.set(ONYXKEYS.FREQUENTLY_USED_EMOJIS, frequentlyEmojisList); + Onyx.merge(ONYXKEYS.FREQUENTLY_USED_EMOJIS, frequentlyEmojisList); return waitForPromisesToResolve().then(() => { // When add new emojis diff --git a/tests/unit/SidebarOrderTest.js b/tests/unit/SidebarOrderTest.js index c4121dde2d2e..ffc619e7d578 100644 --- a/tests/unit/SidebarOrderTest.js +++ b/tests/unit/SidebarOrderTest.js @@ -297,7 +297,8 @@ describe('Sidebar', () => { }) // When the draft is removed - .then(() => Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, {hasDraft: false})) + .then(() => Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, {hasDraft: null})) + // Then the pencil icon goes away .then(() => { expect(screen.queryAllByTestId('Pencil Icon')).toHaveLength(0);