Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/libs/actions/OnyxUpdates.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type {OnyxUpdate} from 'react-native-onyx';
import type {OnyxEntry, OnyxUpdate} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import type {Merge} from 'type-fest';
import {SIDE_EFFECT_REQUEST_COMMANDS, WRITE_COMMANDS} from '@libs/API/types';
import Log from '@libs/Log';
import * as SequentialQueue from '@libs/Network/SequentialQueue';
import Performance from '@libs/Performance';
Expand All @@ -20,6 +21,14 @@ Onyx.connect({
callback: (val) => (lastUpdateIDAppliedToClient = val),
});

let lastOnyxUpdatesFromServer: OnyxEntry<OnyxUpdatesFromServer>;
Onyx.connect({
key: ONYXKEYS.ONYX_UPDATES_FROM_SERVER,
callback: (val) => (lastOnyxUpdatesFromServer = val),
});

const requestsToIgnoreLastCommand: Array<string | undefined> = [WRITE_COMMANDS.SUBMIT_REPORT];

// This promise is used to ensure pusher events are always processed in the order they are received,
// even when such events are received over multiple separate pusher updates.
let pusherEventsPromise = Promise.resolve();
Expand Down Expand Up @@ -138,6 +147,10 @@ function apply({lastUpdateID, type, request, response, updates}: OnyxUpdatesFrom
Onyx.merge(ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT, Number(lastUpdateID));
}
if (type === CONST.ONYX_UPDATE_TYPES.HTTPS && request && response) {
if (request.command === SIDE_EFFECT_REQUEST_COMMANDS.GET_MISSING_ONYX_MESSAGES && requestsToIgnoreLastCommand?.includes(lastOnyxUpdatesFromServer?.request?.command)) {
Log.info(`[OnyxUpdateManager] GetMissingOnyxMessages will not update Onyx for the last command: ${lastOnyxUpdatesFromServer?.request?.command}`);
return Promise.resolve();
}
return applyHTTPSOnyxUpdates(request, response);
}
if (type === CONST.ONYX_UPDATE_TYPES.PUSHER && updates) {
Expand Down
Loading