From eedde25d182148ed584de06c231043ad4980090c Mon Sep 17 00:00:00 2001 From: daledah Date: Tue, 17 Sep 2024 15:29:16 +0700 Subject: [PATCH] fix: Verify button does not show loading indicator after entering magic code --- src/libs/actions/Card.ts | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Card.ts b/src/libs/actions/Card.ts index 15d1eadb662d..447871a2c510 100644 --- a/src/libs/actions/Card.ts +++ b/src/libs/actions/Card.ts @@ -198,8 +198,32 @@ function revealVirtualCardDetails(cardID: number, validateCode: string): Promise return new Promise((resolve, reject) => { const parameters: RevealExpensifyCardDetailsParams = {cardID, validateCode}; + const optimisticData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.ACCOUNT, + value: {isLoading: true}, + }, + ]; + + const successData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.ACCOUNT, + value: {isLoading: false}, + }, + ]; + + const failureData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.ACCOUNT, + value: {isLoading: false}, + }, + ]; + // eslint-disable-next-line rulesdir/no-api-side-effects-method - API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.REVEAL_EXPENSIFY_CARD_DETAILS, parameters) + API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.REVEAL_EXPENSIFY_CARD_DETAILS, parameters, {optimisticData, successData, failureData}) .then((response) => { if (response?.jsonCode !== CONST.JSON_CODE.SUCCESS) { if (response?.message === 'Incorrect or invalid magic code. Please try again.') {