Skip to content

Commit

Permalink
use GetMissingOnyxMessagesForPushNotification when filling onyx updat…
Browse files Browse the repository at this point in the history
…e gaps from push notifications
  • Loading branch information
arosiclair committed Apr 1, 2024
1 parent c555004 commit 837eb25
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/libs/actions/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -278,9 +279,10 @@ function finalReconnectAppAfterActivatingReliableUpdates(): Promise<void | OnyxT
* @param [updateIDFrom] the ID of the Onyx update that we want to start fetching from
* @param [updateIDTo] the ID of the Onyx update that we want to fetch up to
*/
function getMissingOnyxUpdates(updateIDFrom = 0, updateIDTo: number | string = 0): Promise<void | OnyxTypes.Response> {
function getMissingOnyxUpdates(updateIDFrom = 0, updateIDTo: number | string = 0, updateType: OnyxUpdatesType = 'pusher'): Promise<void | OnyxTypes.Response> {
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,
Expand All @@ -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());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/OnyxUpdateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default () => {
previousUpdateIDFromServer,
lastUpdateIDAppliedToClient,
});
canUnpauseQueuePromise = App.getMissingOnyxUpdates(lastUpdateIDAppliedToClient, previousUpdateIDFromServer);
canUnpauseQueuePromise = App.getMissingOnyxUpdates(lastUpdateIDAppliedToClient, previousUpdateIDFromServer, value.type);
}

canUnpauseQueuePromise.finally(() => {
Expand Down
6 changes: 4 additions & 2 deletions src/types/onyx/OnyxUpdatesFromServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ type OnyxUpdateEvent = {
};

type OnyxUpdatesFromServer = {
type: 'https' | 'pusher' | 'airship';
type: OnyxUpdatesType;
lastUpdateID: number | string;
previousUpdateID: number | string;
request?: Request;
response?: Response;
updates?: OnyxUpdateEvent[];
};

export type {OnyxUpdatesFromServer, OnyxUpdateEvent, OnyxServerUpdate};
type OnyxUpdatesType = 'https' | 'pusher' | 'airship';

export type {OnyxUpdatesFromServer, OnyxUpdateEvent, OnyxServerUpdate, OnyxUpdatesType};

0 comments on commit 837eb25

Please sign in to comment.