Skip to content

Commit dac25c7

Browse files
authored
Merge pull request Expensify#89465 from shubham1206agra/refactor-requestUnlockAccount
Refactor: isolate requestUnlockAccount from ONYXKEYS.SESSION Onyx data
2 parents 75b496e + daebac7 commit dac25c7

3 files changed

Lines changed: 5 additions & 14 deletions

File tree

src/libs/actions/User.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,9 +1509,9 @@ function lockAccount(accountID?: number, domainAccountID?: number, domainName?:
15091509
return API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.LOCK_ACCOUNT, params, {optimisticData, successData, failureData});
15101510
}
15111511

1512-
function requestUnlockAccount(accountID?: number) {
1512+
function requestUnlockAccount(accountID: number) {
15131513
const params: LockAccountParams = {
1514-
accountID: accountID ?? currentUserAccountID,
1514+
accountID,
15151515
};
15161516

15171517
API.write(WRITE_COMMANDS.REQUEST_UNLOCK_ACCOUNT, params);

src/pages/settings/Security/LockAccount/UnlockAccountPage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import ConfirmationPage from '@components/ConfirmationPage';
33
import HeaderWithBackButton from '@components/HeaderWithBackButton';
44
import ScreenWrapper from '@components/ScreenWrapper';
55
import ScrollView from '@components/ScrollView';
6+
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
67
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
78
import useLocalize from '@hooks/useLocalize';
89
import useThemeStyles from '@hooks/useThemeStyles';
@@ -12,6 +13,7 @@ import ROUTES from '@src/ROUTES';
1213

1314
function UnlockAccountPage() {
1415
const {translate} = useLocalize();
16+
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
1517
const styles = useThemeStyles();
1618
const icons = useMemoizedLazyExpensifyIcons(['EmptyStateSpyPigeon']);
1719

@@ -33,7 +35,7 @@ function UnlockAccountPage() {
3335
descriptionStyle={styles.colorMuted}
3436
buttonText={translate('unlockAccountPage.chatWithConcierge')}
3537
onButtonPress={() => {
36-
requestUnlockAccount();
38+
requestUnlockAccount(currentUserPersonalDetails.accountID);
3739
Navigation.navigate(ROUTES.CONCIERGE);
3840
}}
3941
containerStyle={styles.h100}

tests/actions/UserTest.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -799,17 +799,6 @@ describe('actions/User', () => {
799799

800800
expect(mockAPI.write).toHaveBeenCalledWith(WRITE_COMMANDS.REQUEST_UNLOCK_ACCOUNT, {accountID});
801801
});
802-
803-
it('should fall back to currentUserAccountID when no accountID is provided', async () => {
804-
const currentAccountID = 888;
805-
await Onyx.merge(ONYXKEYS.SESSION, {accountID: currentAccountID, email: 'user@expensify.com'});
806-
await waitForBatchedUpdates();
807-
808-
UserActions.requestUnlockAccount();
809-
await waitForBatchedUpdates();
810-
811-
expect(mockAPI.write).toHaveBeenCalledWith(WRITE_COMMANDS.REQUEST_UNLOCK_ACCOUNT, {accountID: currentAccountID});
812-
});
813802
});
814803

815804
describe('respondToProactiveAppReview', () => {

0 commit comments

Comments
 (0)