Skip to content

Commit ae8600c

Browse files
committed
update changes
1 parent c98fb52 commit ae8600c

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

src/hooks/useTrialPaymentReminder.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {hasCompletedGuidedSetupFlowSelector} from '@selectors/Onboarding';
21
import {useCallback, useEffect, useMemo, useRef, useState} from 'react';
32
import type {ValueOf} from 'type-fest';
43
import {calculateRemainingTrialSeconds, calculateTrialDayNumber, doesUserHavePaymentCardAdded, isUserOnFreeTrial} from '@libs/SubscriptionUtils';
@@ -11,11 +10,11 @@ import useOnyx from './useOnyx';
1110
const FIVE_MINUTES_MS = 5 * 60 * 1000;
1211
const TWENTY_FOUR_HOURS_IN_SECONDS = 24 * 60 * 60;
1312

14-
/** Waiting for onboarding data to load */
13+
/** Waiting for trial data to load */
1514
const DELAY_LOADING = 'loading';
16-
/** Onboarding not yet complete, waiting for completion */
15+
/** No trial yet, waiting for workspace creation */
1716
const DELAY_WAITING = 'waiting';
18-
/** Onboarding just completed, 5-minute timer running */
17+
/** Trial just started, 5-minute timer running */
1918
const DELAY_TIMING = 'timing';
2019
/** Ready to show modal */
2120
const DELAY_NO_DELAY = 'no_delay';
@@ -95,30 +94,27 @@ function computeCurrentVariation(firstDayFreeTrial: string | undefined, lastDayF
9594
}
9695

9796
function useTrialPaymentReminder() {
98-
const [firstDayFreeTrial] = useOnyx(ONYXKEYS.NVP_FIRST_DAY_FREE_TRIAL);
97+
const [firstDayFreeTrial, firstDayFreeTrialResult] = useOnyx(ONYXKEYS.NVP_FIRST_DAY_FREE_TRIAL);
9998
const [lastDayFreeTrial] = useOnyx(ONYXKEYS.NVP_LAST_DAY_FREE_TRIAL);
10099
const [billingFundID] = useOnyx(ONYXKEYS.NVP_BILLING_FUND_ID);
101100
const [dismissedVariation, dismissedVariationResult] = useOnyx(ONYXKEYS.NVP_TRIAL_PAYMENT_REMINDER_DISMISSED);
102-
const [isOnboardingCompleted] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {
103-
selector: hasCompletedGuidedSetupFlowSelector,
104-
});
105101

106102
const [delayState, setDelayState] = useState<DelayState>(DELAY_STATE.LOADING);
107103

108104
useEffect(() => {
109-
if (isOnboardingCompleted === undefined) {
105+
if (isLoadingOnyxValue(firstDayFreeTrialResult)) {
110106
return;
111107
}
112108

113109
if (delayState === DELAY_STATE.LOADING) {
114-
setDelayState(isOnboardingCompleted ? DELAY_STATE.NO_DELAY : DELAY_STATE.WAITING);
110+
setDelayState(firstDayFreeTrial ? DELAY_STATE.NO_DELAY : DELAY_STATE.WAITING);
115111
return;
116112
}
117113

118-
if (delayState === DELAY_STATE.WAITING && isOnboardingCompleted) {
114+
if (delayState === DELAY_STATE.WAITING && firstDayFreeTrial) {
119115
setDelayState(DELAY_STATE.TIMING);
120116
}
121-
}, [delayState, isOnboardingCompleted]);
117+
}, [delayState, firstDayFreeTrial, firstDayFreeTrialResult]);
122118

123119
// Run 5-minute timer when in 'timing' state
124120
useEffect(() => {

0 commit comments

Comments
 (0)