Skip to content

Commit

Permalink
Merge pull request #18464 from Expensify/Rory-RemoveOnyxMethodConst
Browse files Browse the repository at this point in the history
[No QA] Use Onyx.METHOD and remove redundant CONST.ONYX.METHOD
  • Loading branch information
luacmartins authored May 5, 2023
2 parents a3aa887 + 8c6a088 commit 3585329
Show file tree
Hide file tree
Showing 18 changed files with 318 additions and 325 deletions.
7 changes: 0 additions & 7 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -1067,13 +1067,6 @@ const CONST = {
// Since size cant be null, we have to define some initial value.
INITIAL_SIZE: 1, // 1 was chosen because there is a very low probability that initialized component will have such size.
},

ONYX: {
METHOD: {
MERGE: 'merge',
SET: 'set',
},
},
MICROSECONDS_PER_MS: 1000,
RED_BRICK_ROAD_PENDING_ACTION: {
ADD: 'add',
Expand Down
18 changes: 9 additions & 9 deletions src/libs/actions/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function setLocale(locale) {
// Optimistically change preferred locale
const optimisticData = [
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.NVP_PREFERRED_LOCALE,
value: locale,
},
Expand Down Expand Up @@ -147,21 +147,21 @@ function openApp() {
API.read('OpenApp', {policyIDList: getNonOptimisticPolicyIDs(policies)}, {
optimisticData: [
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.IS_LOADING_REPORT_DATA,
value: true,
},
],
successData: [
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.IS_LOADING_REPORT_DATA,
value: false,
},
],
failureData: [
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.IS_LOADING_REPORT_DATA,
value: false,
},
Expand All @@ -178,17 +178,17 @@ function openApp() {
function reconnectApp() {
API.write(CONST.NETWORK.COMMAND.RECONNECT_APP, {policyIDList: getNonOptimisticPolicyIDs(allPolicies)}, {
optimisticData: [{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.IS_LOADING_REPORT_DATA,
value: true,
}],
successData: [{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.IS_LOADING_REPORT_DATA,
value: false,
}],
failureData: [{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.IS_LOADING_REPORT_DATA,
value: false,
}],
Expand Down Expand Up @@ -275,7 +275,7 @@ function openProfile() {
timezone: JSON.stringify(newTimezoneData),
}, {
optimisticData: [{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.PERSONAL_DETAILS,
value: {
[currentUserEmail]: {
Expand All @@ -284,7 +284,7 @@ function openProfile() {
},
}],
failureData: [{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.PERSONAL_DETAILS,
value: {
[currentUserEmail]: {
Expand Down
28 changes: 14 additions & 14 deletions src/libs/actions/BankAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function getVBBADataForOnyx() {
return {
optimisticData: [
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT,
value: {
isLoading: true,
Expand All @@ -74,7 +74,7 @@ function getVBBADataForOnyx() {
],
successData: [
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT,
value: {
isLoading: false,
Expand All @@ -84,7 +84,7 @@ function getVBBADataForOnyx() {
],
failureData: [
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT,
value: {
isLoading: false,
Expand Down Expand Up @@ -141,7 +141,7 @@ function addPersonalBankAccount(account) {
const onyxData = {
optimisticData: [
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.PERSONAL_BANK_ACCOUNT,
value: {
isLoading: true,
Expand All @@ -152,7 +152,7 @@ function addPersonalBankAccount(account) {
],
successData: [
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.PERSONAL_BANK_ACCOUNT,
value: {
isLoading: false,
Expand All @@ -163,7 +163,7 @@ function addPersonalBankAccount(account) {
],
failureData: [
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.PERSONAL_BANK_ACCOUNT,
value: {
isLoading: false,
Expand All @@ -184,7 +184,7 @@ function deletePaymentBankAccount(bankAccountID) {
}, {
optimisticData: [
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.BANK_ACCOUNT_LIST}`,
value: {[bankAccountID]: {pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE}},
},
Expand All @@ -194,7 +194,7 @@ function deletePaymentBankAccount(bankAccountID) {
// so we are setting the bankAccount to null here to ensure that it gets cleared out once we come back online.
successData: [
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.BANK_ACCOUNT_LIST}`,
value: {[bankAccountID]: null},
},
Expand Down Expand Up @@ -235,22 +235,22 @@ function validateBankAccount(bankAccountID, validateCode) {
validateCode,
}, {
optimisticData: [{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT,
value: {
isLoading: true,
errors: null,
},
}],
successData: [{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT,
value: {
isLoading: false,
},
}],
failureData: [{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT,
value: {
isLoading: false,
Expand All @@ -263,7 +263,7 @@ function openReimbursementAccountPage(stepToOpen, subStep, localCurrentStep) {
const onyxData = {
optimisticData: [
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT,
value: {
isLoading: true,
Expand All @@ -272,7 +272,7 @@ function openReimbursementAccountPage(stepToOpen, subStep, localCurrentStep) {
],
successData: [
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT,
value: {
isLoading: false,
Expand All @@ -281,7 +281,7 @@ function openReimbursementAccountPage(stepToOpen, subStep, localCurrentStep) {
],
failureData: [
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT,
value: {
isLoading: false,
Expand Down
7 changes: 4 additions & 3 deletions src/libs/actions/Chronos.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _ from 'underscore';
import Onyx from 'react-native-onyx';
import CONST from '../../CONST';
import ONYXKEYS from '../../ONYXKEYS';
import * as API from '../API';
Expand All @@ -12,7 +13,7 @@ import * as API from '../API';
const removeEvent = (reportID, reportActionID, eventID, events) => {
const optimisticData = [
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
value: {
[reportActionID]: {
Expand All @@ -27,7 +28,7 @@ const removeEvent = (reportID, reportActionID, eventID, events) => {

const successData = [
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
value: {
[reportActionID]: {
Expand All @@ -39,7 +40,7 @@ const removeEvent = (reportID, reportActionID, eventID, events) => {

const failureData = [
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
value: {
[reportActionID]: {
Expand Down
Loading

0 comments on commit 3585329

Please sign in to comment.