diff --git a/src/libs/actions/App.ts b/src/libs/actions/App.ts index 3a9ab4c52b3c..63bec7aaab80 100644 --- a/src/libs/actions/App.ts +++ b/src/libs/actions/App.ts @@ -29,6 +29,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import type {Route} from '@src/ROUTES'; import ROUTES from '@src/ROUTES'; import type * as OnyxTypes from '@src/types/onyx'; +import type {OnyxUpdatesType} from '@src/types/onyx/OnyxUpdatesFromServer'; import type {SelectedTimezone} from '@src/types/onyx/PersonalDetails'; import type {OnyxData} from '@src/types/onyx/Request'; import * as Policy from './Policy'; @@ -278,9 +279,10 @@ function finalReconnectAppAfterActivatingReliableUpdates(): Promise { +function getMissingOnyxUpdates(updateIDFrom = 0, updateIDTo: number | string = 0, updateType: OnyxUpdatesType = 'pusher'): Promise { console.debug(`[OnyxUpdates] Fetching missing updates updateIDFrom: ${updateIDFrom} and updateIDTo: ${updateIDTo}`); + const command = updateType === 'airship' ? SIDE_EFFECT_REQUEST_COMMANDS.GET_MISSING_ONYX_MESSAGES_FOR_PUSH_NOTIFICATION : SIDE_EFFECT_REQUEST_COMMANDS.GET_MISSING_ONYX_MESSAGES; const parameters: GetMissingOnyxMessagesParams = { updateIDFrom, updateIDTo, @@ -290,7 +292,7 @@ function getMissingOnyxUpdates(updateIDFrom = 0, updateIDTo: number | string = 0 // DO NOT FOLLOW THIS PATTERN!!!!! // It was absolutely necessary in order to block OnyxUpdates while fetching the missing updates from the server or else the udpates aren't applied in the proper order. // eslint-disable-next-line rulesdir/no-api-side-effects-method - return API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.GET_MISSING_ONYX_MESSAGES, parameters, getOnyxDataForOpenOrReconnect()); + return API.makeRequestWithSideEffects(command, parameters, getOnyxDataForOpenOrReconnect()); } /** diff --git a/src/libs/actions/OnyxUpdateManager.ts b/src/libs/actions/OnyxUpdateManager.ts index 9c6f30cc5e9e..9b02a7ef2875 100644 --- a/src/libs/actions/OnyxUpdateManager.ts +++ b/src/libs/actions/OnyxUpdateManager.ts @@ -82,7 +82,7 @@ export default () => { previousUpdateIDFromServer, lastUpdateIDAppliedToClient, }); - canUnpauseQueuePromise = App.getMissingOnyxUpdates(lastUpdateIDAppliedToClient, previousUpdateIDFromServer); + canUnpauseQueuePromise = App.getMissingOnyxUpdates(lastUpdateIDAppliedToClient, previousUpdateIDFromServer, value.type); } canUnpauseQueuePromise.finally(() => { diff --git a/src/types/onyx/OnyxUpdatesFromServer.ts b/src/types/onyx/OnyxUpdatesFromServer.ts index 3c6933da19ba..3c4f5cedd6ce 100644 --- a/src/types/onyx/OnyxUpdatesFromServer.ts +++ b/src/types/onyx/OnyxUpdatesFromServer.ts @@ -13,7 +13,7 @@ type OnyxUpdateEvent = { }; type OnyxUpdatesFromServer = { - type: 'https' | 'pusher' | 'airship'; + type: OnyxUpdatesType; lastUpdateID: number | string; previousUpdateID: number | string; request?: Request; @@ -21,4 +21,6 @@ type OnyxUpdatesFromServer = { updates?: OnyxUpdateEvent[]; }; -export type {OnyxUpdatesFromServer, OnyxUpdateEvent, OnyxServerUpdate}; +type OnyxUpdatesType = 'https' | 'pusher' | 'airship'; + +export type {OnyxUpdatesFromServer, OnyxUpdateEvent, OnyxServerUpdate, OnyxUpdatesType};