Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly handle previous data formats when saving the updates from the server to Onyx #27180

Merged
merged 12 commits into from
Sep 17, 2023
13 changes: 13 additions & 0 deletions src/libs/actions/OnyxUpdateManager.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Onyx from 'react-native-onyx';
import _ from 'underscore';
import ONYXKEYS from '../../ONYXKEYS';
import Log from '../Log';
import * as SequentialQueue from '../Network/SequentialQueue';
Expand Down Expand Up @@ -35,6 +36,18 @@ 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 clera the object in Onyx.
danieldoglas marked this conversation as resolved.
Show resolved Hide resolved
if (
!_.isObject(val) ||
!val.hasOwnProperty('type') ||
!(val.type === CONST.ONYX_UPDATE_TYPES.HTTPS && val.hasOwnProperty('request') && val.hasOwnProperty('response')) ||
!(val.type === CONST.ONYX_UPDATE_TYPES.PUSHER && !val.hasOwnProperty('updates'))
) {
Onyx.set(ONYXKEYS.ONYX_UPDATES_FROM_SERVER, null);
return;
}

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