From c854b6b303b8697b4b24fbfd66bbc022e329899c Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Tue, 1 Aug 2023 18:01:55 +0300 Subject: [PATCH] Merge pull request #24003 from Expensify/beaman-revertOnyxDirectCacheAccess [CP Staging] [Revert] Perf/onyx upgrade use cache directly (cherry picked from commit a3c2e1b3cfd92594d5ebbfb75d9c0b0034b146f7) --- 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 c85e36248d4..54fee0a4d00 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", @@ -36796,9 +36796,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", @@ -68564,9 +68564,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 cb3fcb9cf1c..ca311a4090d 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 486108dd56c..d25f44a9aa6 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 69f38fa349a..0e9b7a7c8c0 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 a4a2873399c..7c0e12e6b1b 100644 --- a/tests/unit/SidebarOrderTest.js +++ b/tests/unit/SidebarOrderTest.js @@ -296,7 +296,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);