diff --git a/src/libs/HttpUtils.ts b/src/libs/HttpUtils.ts index 23d280f36644..919b1d88ea56 100644 --- a/src/libs/HttpUtils.ts +++ b/src/libs/HttpUtils.ts @@ -5,7 +5,7 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {RequestType} from '@src/types/onyx/Request'; import type Response from '@src/types/onyx/Response'; -import * as AppUpdate from './actions/AppUpdate'; +import * as UpdateRequired from './actions/UpdateRequired'; import * as NetworkActions from './actions/Network'; import * as ApiUtils from './ApiUtils'; import HttpsError from './Errors/HttpsError'; @@ -131,7 +131,7 @@ function processHTTPRequest(url: string, method: RequestType = 'get', body: Form } if (response.jsonCode === CONST.JSON_CODE.UPDATE_REQUIRED) { // Trigger a modal and disable the app as the user needs to upgrade to the latest minimum version to continue - AppUpdate.triggerUpgradeRequired(); + UpdateRequired.alertUser(); } return response as Promise; }); diff --git a/src/libs/actions/AppUpdate/index.ts b/src/libs/actions/AppUpdate/index.ts index 7db334919b03..69c80a089831 100644 --- a/src/libs/actions/AppUpdate/index.ts +++ b/src/libs/actions/AppUpdate/index.ts @@ -1,6 +1,4 @@ import Onyx from 'react-native-onyx'; -import getEnvironment from '@libs/Environment/getEnvironment'; -import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import updateApp from './updateApp'; @@ -12,17 +10,4 @@ function setIsAppInBeta(isBeta: boolean) { Onyx.set(ONYXKEYS.IS_BETA, isBeta); } -function triggerUpgradeRequired() { - // For now, we will pretty much never have to do this on a platform other than production. - // We should only update the minimum app version in the API after all platforms of a new version have been deployed to PRODUCTION. - // As staging is always ahead of production there is no reason to "force update" those apps. - getEnvironment().then((environment) => { - if (environment !== CONST.ENVIRONMENT.PRODUCTION) { - return; - } - - Onyx.set(ONYXKEYS.UPDATE_REQUIRED, true); - }); -} - -export {triggerUpdateAvailable, setIsAppInBeta, triggerUpgradeRequired, updateApp}; +export {triggerUpdateAvailable, setIsAppInBeta, updateApp}; diff --git a/src/libs/actions/UpdateRequired.ts b/src/libs/actions/UpdateRequired.ts new file mode 100644 index 000000000000..0e27ff15acd0 --- /dev/null +++ b/src/libs/actions/UpdateRequired.ts @@ -0,0 +1,22 @@ +import Onyx from 'react-native-onyx'; +import ONYXKEYS from '@src/ONYXKEYS'; +import getEnvironment from '@libs/Environment/getEnvironment'; +import CONST from '@src/CONST'; + +function alertUser() { + // For now, we will pretty much never have to do this on a platform other than production. + // We should only update the minimum app version in the API after all platforms of a new version have been deployed to PRODUCTION. + // As staging is always ahead of production there is no reason to "force update" those apps. + getEnvironment().then((environment) => { + if (environment !== CONST.ENVIRONMENT.PRODUCTION) { + return; + } + + Onyx.set(ONYXKEYS.UPDATE_REQUIRED, true); + }); +} + +export { + // eslint-disable-next-line import/prefer-default-export + alertUser +}; diff --git a/tests/unit/MigrationTest.js b/tests/unit/MigrationTest.js index ebffc71e4e0e..28d21cd4b11c 100644 --- a/tests/unit/MigrationTest.js +++ b/tests/unit/MigrationTest.js @@ -428,31 +428,6 @@ describe('Migrations', () => { }); })); - it('Should remove any instances of participants found in a report', () => - Onyx.multiSet({ - [`${ONYXKEYS.COLLECTION.REPORT}1`]: { - reportID: 1, - participants: ['fake@test.com'], - participantAccountIDs: [5], - }, - }) - .then(PersonalDetailsByAccountID) - .then(() => { - expect(LogSpy).toHaveBeenCalledWith('[Migrate Onyx] PersonalDetailsByAccountID migration: removing participants from report 1'); - const connectionID = Onyx.connect({ - key: ONYXKEYS.COLLECTION.REPORT, - waitForCollectionCallback: true, - callback: (allReports) => { - Onyx.disconnect(connectionID); - const expectedReport = { - reportID: 1, - participantAccountIDs: [5], - }; - expect(allReports[`${ONYXKEYS.COLLECTION.REPORT}1`]).toMatchObject(expectedReport); - }, - }); - })); - it('Should remove any instances of ownerEmail found in a report', () => Onyx.multiSet({ [`${ONYXKEYS.COLLECTION.REPORT}1`]: {