diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 8f95dff079fc..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'; @@ -30,9 +29,6 @@ const ONYXKEYS = { /** 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', @@ -306,7 +302,6 @@ type OnyxValues = { [ONYXKEYS.DEVICE_ID]: string; [ONYXKEYS.IS_SIDEBAR_LOADED]: boolean; [ONYXKEYS.PERSISTED_REQUESTS]: OnyxTypes.Request[]; - [ONYXKEYS.QUEUED_ONYX_UPDATES]: OnyxUpdate[]; [ONYXKEYS.CURRENT_DATE]: string; [ONYXKEYS.CREDENTIALS]: OnyxTypes.Credentials; [ONYXKEYS.IOU]: OnyxTypes.IOU; diff --git a/src/libs/actions/QueuedOnyxUpdates.ts b/src/libs/actions/QueuedOnyxUpdates.ts index ac94e6f335e3..1707bebd6cb2 100644 --- a/src/libs/actions/QueuedOnyxUpdates.ts +++ b/src/libs/actions/QueuedOnyxUpdates.ts @@ -1,27 +1,21 @@ import Onyx, {OnyxUpdate} 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. let queuedOnyxUpdates: OnyxUpdate[] = []; -Onyx.connect({ - key: ONYXKEYS.QUEUED_ONYX_UPDATES, - callback: (val) => (queuedOnyxUpdates = val ?? []), -}); /** * @param updates Onyx updates to queue for later */ function queueOnyxUpdates(updates: OnyxUpdate[]): Promise { - return Onyx.set(ONYXKEYS.QUEUED_ONYX_UPDATES, [...queuedOnyxUpdates, ...updates]); -} - -function clear() { - Onyx.set(ONYXKEYS.QUEUED_ONYX_UPDATES, null); + queuedOnyxUpdates = queuedOnyxUpdates.concat(updates); + return Promise.resolve(); } function flushQueue(): Promise { - return Onyx.update(queuedOnyxUpdates).then(clear); + return Onyx.update(queuedOnyxUpdates).then(() => { + queuedOnyxUpdates = []; + }); } export {queueOnyxUpdates, flushQueue};