Skip to content

Commit 61d5ec4

Browse files
limichangelimichange
authored andcommitted
feat: test
1 parent b98d15a commit 61d5ec4

File tree

5 files changed

+41
-79
lines changed

5 files changed

+41
-79
lines changed

packages/kit/src/views/Prime/components/PrimeLoginEmailCodeDialogV2/PrimeLoginEmailCodeDialogV2.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ export function PrimeLoginEmailCodeDialogV2(props: {
2020
email: string;
2121
loginWithCode: (args: { code: string; email?: string }) => Promise<void>;
2222
sendCode: (args: { email: string }) => void;
23+
onLoginSuccess: () => void;
2324
}) {
24-
const { email, loginWithCode, sendCode } = props;
25+
const { email, loginWithCode, sendCode, onLoginSuccess } = props;
2526
const [countdown, setCountdown] = useState(COUNTDOWN_TIME);
2627
const [isResending, setIsResending] = useState(false);
2728
const [verificationCode, setVerificationCode] = useState('');
@@ -127,6 +128,8 @@ export function PrimeLoginEmailCodeDialogV2(props: {
127128
email,
128129
});
129130

131+
onLoginSuccess?.();
132+
130133
Toast.success({
131134
title: intl.formatMessage({
132135
id: ETranslations.login_welcome_message,

packages/kit/src/views/Prime/hooks/PrimeSignupTest.tsx

Lines changed: 0 additions & 42 deletions
This file was deleted.

packages/kit/src/views/Prime/hooks/usePrimeAuth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import backgroundApiProxy from '../../../background/instance/backgroundApiProxy'
1414
import { usePrivyUniversal } from './usePrivyUniversal';
1515

1616
export function usePrimeAuth() {
17-
const [primePersistAtom, setPrimePersistAtom] = usePrimePersistAtom();
18-
const [primeInitAtom, setPrimeInitAtom] = usePrimeInitAtom();
17+
const [primePersistAtom] = usePrimePersistAtom();
18+
const [primeInitAtom] = usePrimeInitAtom();
1919

2020
const privy = usePrivyUniversal();
2121
const { logout, getAccessToken } = privy;

packages/kit/src/views/Prime/hooks/usePrimeAuthV2.tsx

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -43,44 +43,42 @@ export function usePrimeAuthV2() {
4343
Toast.success({
4444
title: '🔑 ✅ submitting code',
4545
});
46-
} else if (state.status === 'done') {
47-
Toast.success({
48-
title: '🔑 ✅ User successfully logged in with email',
49-
});
50-
51-
closeDialogs();
5246
} else if (state.status === 'error') {
5347
Toast.error({
5448
title: '🔑 ❌ User failed to log in with email',
5549
});
5650
}
57-
}, [state]);
51+
}, [state.status]);
5852

59-
const loginWithEmail = async () => {
60-
// 1. open dialog
61-
const dialog: IDialogInstance = Dialog.show({
62-
renderContent: (
63-
<PrimeLoginEmailDialogV2
64-
// 2. on email submitted
65-
onEmailSubmitted={async (email) => {
66-
// 3. open code dialog
67-
emailCodeDialogRef.current = Dialog.show({
68-
renderContent: (
69-
// 4. input code
70-
<PrimeLoginEmailCodeDialogV2
71-
sendCode={sendCode}
72-
loginWithCode={loginWithCode}
73-
email={email}
74-
/>
75-
),
76-
});
77-
}}
78-
/>
79-
),
80-
});
53+
const loginWithEmail = async () =>
54+
new Promise((resolve) => {
55+
// 1. open dialog
56+
const dialog: IDialogInstance = Dialog.show({
57+
renderContent: (
58+
<PrimeLoginEmailDialogV2
59+
// 2. on email submitted
60+
onEmailSubmitted={async (email) => {
61+
// 3. open code dialog
62+
emailCodeDialogRef.current = Dialog.show({
63+
renderContent: (
64+
// 4. input code
65+
<PrimeLoginEmailCodeDialogV2
66+
sendCode={sendCode}
67+
loginWithCode={loginWithCode}
68+
email={email}
69+
onLoginSuccess={() => {
70+
resolve(true);
71+
}}
72+
/>
73+
),
74+
});
75+
}}
76+
/>
77+
),
78+
});
8179

82-
emailDialogRef.current = dialog;
83-
};
80+
emailDialogRef.current = dialog;
81+
});
8482

8583
return {
8684
loginWithEmail,

packages/kit/src/views/Prime/pages/PrimeDashboard/PrimeDashboard.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,14 @@ export default function PrimeDashboard() {
113113
try {
114114
setIsLoading(true);
115115

116+
// await 1s
117+
await timerUtils.wait(500);
118+
116119
if (!user?.isLoggedIn) {
117120
await loginWithEmail();
118-
} else if (platformEnv.isNative) {
121+
}
122+
123+
if (platformEnv.isNative) {
119124
ActionList.show({
120125
title: 'Purchase',
121126
onClose: () => {},
@@ -305,8 +310,6 @@ export default function PrimeDashboard() {
305310
PaywallPackages
306311
</Button>
307312
</XStack>
308-
309-
{/* <PrimeSignupTest /> */}
310313
</Page.Body>
311314

312315
<Page.Footer

0 commit comments

Comments
 (0)