diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 0d22d3714fe6..7e18cc0acd98 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -151,8 +151,8 @@ const ONYXKEYS = { /** Whether the user has tried focus mode yet */ NVP_TRY_FOCUS_MODE: 'nvp_tryFocusMode', - /** Whether the user has been shown the hold educational interstitial yet */ - NVP_HOLD_USE_EXPLAINED: 'holdUseExplained', + /** Whether the user has dismissed the hold educational interstitial */ + NVP_DISMISSED_HOLD_USE_EXPLANATION: 'nvp_dismissedHoldUseExplanation', /** Store the state of the subscription */ NVP_PRIVATE_SUBSCRIPTION: 'nvp_private_subscription', @@ -635,7 +635,7 @@ type OnyxValuesMapping = { [ONYXKEYS.NVP_BLOCKED_FROM_CHAT]: string; [ONYXKEYS.NVP_PRIVATE_PUSH_NOTIFICATION_ID]: string; [ONYXKEYS.NVP_TRY_FOCUS_MODE]: boolean; - [ONYXKEYS.NVP_HOLD_USE_EXPLAINED]: boolean; + [ONYXKEYS.NVP_DISMISSED_HOLD_USE_EXPLANATION]: boolean; [ONYXKEYS.FOCUS_MODE_NOTIFICATION]: boolean; [ONYXKEYS.NVP_LAST_PAYMENT_METHOD]: OnyxTypes.LastPaymentMethod; [ONYXKEYS.NVP_RECENT_WAYPOINTS]: OnyxTypes.RecentWaypoint[]; diff --git a/src/components/MoneyRequestHeader.tsx b/src/components/MoneyRequestHeader.tsx index a1f214ae847a..f14fe11f5d74 100644 --- a/src/components/MoneyRequestHeader.tsx +++ b/src/components/MoneyRequestHeader.tsx @@ -54,9 +54,8 @@ function MoneyRequestHeader({report, parentReportAction, policy, shouldUseNarrow const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${(parentReportAction as ReportAction & OriginalMessageIOU)?.originalMessage?.IOUTransactionID ?? -1}`); const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS); const [session] = useOnyx(ONYXKEYS.SESSION); - const [holdUseExplained, holdUseExplainedResult] = useOnyx(ONYXKEYS.NVP_HOLD_USE_EXPLAINED); - const isLoadingHoldUseExplained = isLoadingOnyxValue(holdUseExplainedResult); - + const [dismissedHoldUseExplanation, dismissedHoldUseExplanationResult] = useOnyx(ONYXKEYS.NVP_DISMISSED_HOLD_USE_EXPLANATION, {initialValue: true}); + const isLoadingHoldUseExplained = isLoadingOnyxValue(dismissedHoldUseExplanationResult); const styles = useThemeStyles(); const theme = useTheme(); const {translate} = useLocalize(); @@ -180,8 +179,8 @@ function MoneyRequestHeader({report, parentReportAction, policy, shouldUseNarrow if (isLoadingHoldUseExplained) { return; } - setShouldShowHoldMenu(isOnHold && !holdUseExplained); - }, [isOnHold, holdUseExplained, isLoadingHoldUseExplained]); + setShouldShowHoldMenu(isOnHold && !dismissedHoldUseExplanation); + }, [dismissedHoldUseExplanation, isLoadingHoldUseExplained, isOnHold]); useEffect(() => { if (!shouldShowHoldMenu) { @@ -198,7 +197,7 @@ function MoneyRequestHeader({report, parentReportAction, policy, shouldUseNarrow }, [isSmallScreenWidth, shouldShowHoldMenu]); const handleHoldRequestClose = () => { - IOU.setShownHoldUseExplanation(); + IOU.dismissHoldUseExplanation(); }; if (canDeleteRequest) { diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index bbc377b780d0..9d22f2358f1c 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -19,6 +19,7 @@ import type { RequestMoneyParams, SendInvoiceParams, SendMoneyParams, + SetNameValuePairParams, SplitBillParams, StartSplitBillParams, SubmitReportParams, @@ -6677,8 +6678,23 @@ function setMoneyRequestTaxAmount(transactionID: string, taxAmount: number | nul Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {taxAmount}); } -function setShownHoldUseExplanation() { - Onyx.set(ONYXKEYS.NVP_HOLD_USE_EXPLAINED, true); +function dismissHoldUseExplanation() { + const parameters: SetNameValuePairParams = { + name: ONYXKEYS.NVP_DISMISSED_HOLD_USE_EXPLANATION, + value: true, + }; + + const optimisticData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.NVP_DISMISSED_HOLD_USE_EXPLANATION, + value: true, + }, + ]; + + API.write(WRITE_COMMANDS.SET_NAME_VALUE_PAIR, parameters, { + optimisticData, + }); } /** @@ -6977,7 +6993,8 @@ export { setMoneyRequestTag, setMoneyRequestTaxAmount, setMoneyRequestTaxRate, - setShownHoldUseExplanation, + dismissHoldUseExplanation, + updateMoneyRequestDate, setSplitShares, resetSplitShares, setIndividualShare, @@ -6993,7 +7010,6 @@ export { updateMoneyRequestAmountAndCurrency, updateMoneyRequestBillable, updateMoneyRequestCategory, - updateMoneyRequestDate, updateMoneyRequestDescription, updateMoneyRequestDistance, updateMoneyRequestMerchant, diff --git a/src/pages/ProcessMoneyRequestHoldPage.tsx b/src/pages/ProcessMoneyRequestHoldPage.tsx index ad04ada569bb..76fcfec2937f 100644 --- a/src/pages/ProcessMoneyRequestHoldPage.tsx +++ b/src/pages/ProcessMoneyRequestHoldPage.tsx @@ -15,7 +15,7 @@ function ProcessMoneyRequestHoldPage() { const {translate} = useLocalize(); const onConfirm = useCallback(() => { - IOU.setShownHoldUseExplanation(); + IOU.dismissHoldUseExplanation(); Navigation.goBack(); }, []);