Skip to content

Commit

Permalink
Extract getting personal details to separate function
Browse files Browse the repository at this point in the history
  • Loading branch information
MaciejSWM committed Feb 19, 2024
1 parent 22a6bd6 commit b9d88a3
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/libs/actions/Welcome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import type {EmptyObject} from '@src/types/utils/EmptyObject';

let hasSelectedPurpose: boolean | undefined;
let hasProvidedPersonalDetails: boolean | undefined;
let currentUserAccountID: number | undefined;
let isFirstTimeNewExpensifyUser: boolean | undefined;
let hasDismissedModal: boolean | undefined;
let hasSelectedChoice: boolean | undefined;
Expand Down Expand Up @@ -92,6 +91,21 @@ function checkOnReady() {
resolveIsReadyPromise?.();
}

function getPersonalDetails(accountID: number | undefined) {
Onyx.connect({
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
initWithStoredValues: true,
callback: (value) => {
if (!value || !accountID) {
return;
}

hasProvidedPersonalDetails = !!value[accountID]?.firstName && !!value[accountID]?.lastName;
isAbleToDetermineOnboardingStatus({onAble: resolveOnboardingFlowStatus});
},
});
}

Onyx.connect({
key: ONYXKEYS.NVP_IS_FIRST_TIME_NEW_EXPENSIFY_USER,
initWithStoredValues: false,
Expand Down Expand Up @@ -170,20 +184,7 @@ Onyx.connect({
return;
}

currentUserAccountID = val.accountID;

Onyx.connect({
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
initWithStoredValues: true,
callback: (value) => {
if (!value || !currentUserAccountID) {
return;
}

hasProvidedPersonalDetails = !!value[currentUserAccountID]?.firstName && !!value[currentUserAccountID]?.lastName;
isAbleToDetermineOnboardingStatus({onAble: resolveOnboardingFlowStatus});
},
});
getPersonalDetails(val.accountID)
},
});

Expand Down

0 comments on commit b9d88a3

Please sign in to comment.