Skip to content

Commit

Permalink
Merge pull request #27180 from Expensify/dsilva_fixDeployBlockerWithOnyx
Browse files Browse the repository at this point in the history
Properly handle previous data formats when saving the updates from the server to Onyx
  • Loading branch information
tgolen authored Sep 17, 2023
2 parents c77814f + 5029f33 commit beaf3fa
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/libs/actions/OnyxUpdateManager.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import Onyx from 'react-native-onyx';
import _ from 'underscore';
import ONYXKEYS from '../../ONYXKEYS';
import Log from '../Log';
import * as SequentialQueue from '../Network/SequentialQueue';
import * as App from './App';
import * as OnyxUpdates from './OnyxUpdates';
import CONST from '../../CONST';

// This file is in charge of looking at the updateIDs coming from the server and comparing them to the last updateID that the client has.
// If the client is behind the server, then we need to
Expand Down Expand Up @@ -35,6 +37,19 @@ export default () => {
return;
}

// Since we used the same key that used to store another object, let's confirm that the current object is
// following the new format before we proceed. If it isn't, then let's clear the object in Onyx.
if (
!_.isObject(val) ||
!_.has(val, 'type') ||
(!(val.type === CONST.ONYX_UPDATE_TYPES.HTTPS && _.has(val, 'request') && _.has(val, 'response')) && !(val.type === CONST.ONYX_UPDATE_TYPES.PUSHER && _.has(val, 'updates')))
) {
console.debug('[OnyxUpdateManager] Invalid format found for updates, cleaning and unpausing the queue');
Onyx.set(ONYXKEYS.ONYX_UPDATES_FROM_SERVER, null);
SequentialQueue.unpause();
return;
}

const updateParams = val;
const lastUpdateIDFromServer = val.lastUpdateID;
const previousUpdateIDFromServer = val.previousUpdateID;
Expand Down

0 comments on commit beaf3fa

Please sign in to comment.