Skip to content

Commit

Permalink
remove 'resetMoneyRequestInfo' and remaining 'ONYXKEYS.IOU'
Browse files Browse the repository at this point in the history
  • Loading branch information
brunovjk committed Apr 24, 2024
1 parent ef390bd commit 66d906e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 35 deletions.
4 changes: 0 additions & 4 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ const ONYXKEYS = {
CREDENTIALS: 'credentials',
STASHED_CREDENTIALS: 'stashedCredentials',

// Contains loading data for the IOU feature (MoneyRequestModal, IOUDetail, & MoneyRequestPreview Components)
IOU: 'iou',

/** Keeps track if there is modal currently visible or not */
MODAL: 'modal',

Expand Down Expand Up @@ -580,7 +577,6 @@ type OnyxValuesMapping = {
[ONYXKEYS.CURRENT_DATE]: string;
[ONYXKEYS.CREDENTIALS]: OnyxTypes.Credentials;
[ONYXKEYS.STASHED_CREDENTIALS]: OnyxTypes.Credentials;
[ONYXKEYS.IOU]: OnyxTypes.IOU;
[ONYXKEYS.MODAL]: OnyxTypes.Modal;
[ONYXKEYS.NETWORK]: OnyxTypes.Network;
[ONYXKEYS.NEW_GROUP_CHAT_DRAFT]: OnyxTypes.NewGroupChatDraft;
Expand Down
38 changes: 7 additions & 31 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,29 +411,6 @@ function updateDistanceRequestRate(transactionID: string, rateID: string, policy
Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {comment: {customUnit: {customUnitRateID: rateID}}});
}

/** Reset expense info from the store with its initial value */
function resetMoneyRequestInfo(id = '') {
// Disabling this line since currentDate can be an empty string
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const created = currentDate || format(new Date(), CONST.DATE.FNS_FORMAT_STRING);
Onyx.merge(ONYXKEYS.IOU, {
id,
amount: 0,
currency: currentUserPersonalDetails.localCurrencyCode ?? CONST.CURRENCY.USD,
comment: '',
participants: [],
merchant: CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT,
category: '',
tag: '',
created,
receiptPath: '',
receiptFilename: '',
transactionID: '',
billable: null,
isSplitRequest: false,
});
}

/** Helper function to get the receipt error for expenses, or the generic error if there's no receipt */
function getReceiptError(receipt?: Receipt, filename?: string, isScanRequest = true, errorKey?: number): Errors | ErrorFields {
return isEmptyObject(receipt) || !isScanRequest
Expand Down Expand Up @@ -2899,7 +2876,7 @@ function requestMoney(

// eslint-disable-next-line rulesdir/no-multiple-api-calls
API.write(WRITE_COMMANDS.REQUEST_MONEY, parameters, onyxData);
resetMoneyRequestInfo();

}
}

Expand Down Expand Up @@ -3068,7 +3045,7 @@ function trackExpense(
};

API.write(WRITE_COMMANDS.TRACK_EXPENSE, parameters, onyxData);
resetMoneyRequestInfo();

}
}
if (action === CONST.IOU.ACTION.SHARE) {
Expand Down Expand Up @@ -3571,7 +3548,7 @@ function splitBill({

API.write(WRITE_COMMANDS.SPLIT_BILL, parameters, onyxData);

resetMoneyRequestInfo();

Navigation.dismissModal(existingSplitChatReportID);
Report.notifyNewAction(splitData.chatReportID, currentUserAccountID);
}
Expand Down Expand Up @@ -3630,7 +3607,7 @@ function splitBillAndOpenReport({

API.write(WRITE_COMMANDS.SPLIT_BILL_AND_OPEN_REPORT, parameters, onyxData);

resetMoneyRequestInfo();

Navigation.dismissModal(splitData.chatReportID);
Report.notifyNewAction(splitData.chatReportID, currentUserAccountID);
}
Expand Down Expand Up @@ -3930,7 +3907,7 @@ function startSplitBill({

API.write(WRITE_COMMANDS.START_SPLIT_BILL, parameters, {optimisticData, successData, failureData});

resetMoneyRequestInfo();

Navigation.dismissModalWithReport(splitChatReport);
Report.notifyNewAction(splitChatReport.chatReportID ?? '', currentUserAccountID);
}
Expand Down Expand Up @@ -5274,7 +5251,7 @@ function sendMoneyElsewhere(report: OnyxEntry<OnyxTypes.Report>, amount: number,

API.write(WRITE_COMMANDS.SEND_MONEY_ELSEWHERE, params, {optimisticData, successData, failureData});

resetMoneyRequestInfo();

Navigation.dismissModal(params.chatReportID);
Report.notifyNewAction(params.chatReportID, managerID);
}
Expand All @@ -5288,7 +5265,7 @@ function sendMoneyWithWallet(report: OnyxEntry<OnyxTypes.Report>, amount: number

API.write(WRITE_COMMANDS.SEND_MONEY_WITH_WALLET, params, {optimisticData, successData, failureData});

resetMoneyRequestInfo();

Navigation.dismissModal(params.chatReportID);
Report.notifyNewAction(params.chatReportID, managerID);
}
Expand Down Expand Up @@ -6004,7 +5981,6 @@ export {
putOnHold,
replaceReceipt,
requestMoney,
resetMoneyRequestInfo,
savePreferredPaymentMethod,
sendMoneyElsewhere,
sendMoneyWithWallet,
Expand Down

0 comments on commit 66d906e

Please sign in to comment.