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

Don't clear error for failure data #12579

Merged
merged 3 commits into from
Nov 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/libs/actions/PaymentMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,24 @@ function openPaymentsPage() {
*
*/
function getMakeDefaultPaymentOnyxData(bankAccountID, fundID, previousPaymentMethod, currentPaymentMethod, isOptimisticData = true) {
const onxyData = [
const onyxData = [
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
key: ONYXKEYS.USER_WALLET,
value: {
walletLinkedAccountID: bankAccountID || fundID,
walletLinkedAccountType: bankAccountID ? CONST.PAYMENT_METHODS.BANK_ACCOUNT : CONST.PAYMENT_METHODS.DEBIT_CARD,
errors: null,
},
},
];

// Only clear the error if this is optimistic data. If this is failure data, we do not want to clear the error that came from the server.
if (isOptimisticData) {
onyxData[0].value.errors = null;
}

if (previousPaymentMethod) {
onxyData.push({
onyxData.push({
onyxMethod: CONST.ONYX.METHOD.MERGE,
key: previousPaymentMethod.accountType === CONST.PAYMENT_METHODS.BANK_ACCOUNT ? ONYXKEYS.BANK_ACCOUNT_LIST : ONYXKEYS.CARD_LIST,
value: {
Expand All @@ -145,7 +149,7 @@ function getMakeDefaultPaymentOnyxData(bankAccountID, fundID, previousPaymentMet
}

if (currentPaymentMethod) {
onxyData.push({
onyxData.push({
onyxMethod: CONST.ONYX.METHOD.MERGE,
key: currentPaymentMethod.accountType === CONST.PAYMENT_METHODS.BANK_ACCOUNT ? ONYXKEYS.BANK_ACCOUNT_LIST : ONYXKEYS.CARD_LIST,
value: {
Expand All @@ -156,7 +160,7 @@ function getMakeDefaultPaymentOnyxData(bankAccountID, fundID, previousPaymentMet
});
}

return onxyData;
return onyxData;
}

/**
Expand Down