From 1eb31bc8cbd51cb0edf4966dbba970e5570e4198 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Mon, 21 Aug 2023 09:01:26 -1000 Subject: [PATCH 1/5] Save queued updates to memory only --- src/ONYXKEYS.js | 3 --- src/libs/actions/QueuedOnyxUpdates.js | 16 +++++----------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/ONYXKEYS.js b/src/ONYXKEYS.js index 27e7f9f0ecf3..093ef83ef62b 100755 --- a/src/ONYXKEYS.js +++ b/src/ONYXKEYS.js @@ -24,9 +24,6 @@ export default { // Note: These are Persisted Requests - not all requests in the main queue as the key name might lead one to believe PERSISTED_REQUESTS: 'networkRequestQueue', - // Onyx updates from a response, or success or failure data from a request. - QUEUED_ONYX_UPDATES: 'queuedOnyxUpdates', - // Stores current date CURRENT_DATE: 'currentDate', diff --git a/src/libs/actions/QueuedOnyxUpdates.js b/src/libs/actions/QueuedOnyxUpdates.js index 486108dd56cf..f13ce83dcb97 100644 --- a/src/libs/actions/QueuedOnyxUpdates.js +++ b/src/libs/actions/QueuedOnyxUpdates.js @@ -1,24 +1,18 @@ -import Onyx from 'react-native-onyx'; -import ONYXKEYS from '../../ONYXKEYS'; - -// In this file we manage a queue of Onyx updates while the SequentialQueue is processing. There are functions to get the updates and clear the queue after saving the updates in Onyx. +// In this file we manage a queue of Onyx updates while the SequentialQueue is processing. There are functions to get the updates and clear the queue after saving the updates. let queuedOnyxUpdates = []; -Onyx.connect({ - key: ONYXKEYS.QUEUED_ONYX_UPDATES, - callback: (val) => (queuedOnyxUpdates = val || []), -}); /** * @param {Array} updates Onyx updates to queue for later - * @returns {Promise} + * @returns {Promise} */ function queueOnyxUpdates(updates) { - return Onyx.set(ONYXKEYS.QUEUED_ONYX_UPDATES, [...queuedOnyxUpdates, ...updates]); + queuedOnyxUpdates.concat(updates); + return Promise.resolve(); } function clear() { - Onyx.set(ONYXKEYS.QUEUED_ONYX_UPDATES, null); + queuedOnyxUpdates = []; } /** From 6307d475240e777bc6f3de1f167a6dc5ed802310 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Mon, 21 Aug 2023 09:05:30 -1000 Subject: [PATCH 2/5] concat returns a new array --- src/libs/actions/QueuedOnyxUpdates.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/QueuedOnyxUpdates.js b/src/libs/actions/QueuedOnyxUpdates.js index f13ce83dcb97..d8f2d0b2519c 100644 --- a/src/libs/actions/QueuedOnyxUpdates.js +++ b/src/libs/actions/QueuedOnyxUpdates.js @@ -7,7 +7,7 @@ let queuedOnyxUpdates = []; * @returns {Promise} */ function queueOnyxUpdates(updates) { - queuedOnyxUpdates.concat(updates); + queuedOnyxUpdates = queuedOnyxUpdates.concat(updates); return Promise.resolve(); } From 3151b5f31adb04fb4a31324157653fe8901cc59c Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Fri, 1 Sep 2023 13:09:15 -1000 Subject: [PATCH 3/5] remove type --- src/ONYXKEYS.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index f381fab3fc64..d0e97e438736 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -302,7 +302,6 @@ type OnyxValues = { [ONYXKEYS.IS_SIDEBAR_LOADED]: boolean; [ONYXKEYS.SHOW_DOWNLOAD_APP_BANNER]: boolean; [ONYXKEYS.PERSISTED_REQUESTS]: OnyxTypes.Request[]; - [ONYXKEYS.QUEUED_ONYX_UPDATES]: OnyxTypes.QueuedOnyxUpdates; [ONYXKEYS.CURRENT_DATE]: string; [ONYXKEYS.CREDENTIALS]: OnyxTypes.Credentials; [ONYXKEYS.IOU]: OnyxTypes.IOU; From fd3c662cf8ef13758a52239db421ee8bfc7b2ae8 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Fri, 15 Sep 2023 10:14:34 -1000 Subject: [PATCH 4/5] Fix import --- src/libs/actions/QueuedOnyxUpdates.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/QueuedOnyxUpdates.js b/src/libs/actions/QueuedOnyxUpdates.js index bd83e7db3c01..d8e80613406e 100644 --- a/src/libs/actions/QueuedOnyxUpdates.js +++ b/src/libs/actions/QueuedOnyxUpdates.js @@ -1,5 +1,6 @@ -// In this file we manage a queue of Onyx updates while the SequentialQueue is processing. There are functions to get the updates and clear the queue after saving the updates. +import Onyx from 'react-native-onyx'; +// In this file we manage a queue of Onyx updates while the SequentialQueue is processing. There are functions to get the updates and clear the queue after saving the updates. let queuedOnyxUpdates = []; /** From 02b5eef105349053f4f8adef55d9b9d85289a820 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Thu, 28 Sep 2023 17:23:54 +0800 Subject: [PATCH 5/5] Update ONYXKEYS.ts Remove unused import --- src/ONYXKEYS.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 14db8d2ab0c2..7a0def596774 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -1,5 +1,4 @@ import {ValueOf} from 'type-fest'; -import {OnyxUpdate} from 'react-native-onyx'; import DeepValueOf from './types/utils/DeepValueOf'; import * as OnyxTypes from './types/onyx'; import CONST from './CONST';