Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3693666
D11807.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D11807.diff
View Options
diff --git a/native/account/registration/existing-ethereum-account.react.js b/native/account/registration/existing-ethereum-account.react.js
--- a/native/account/registration/existing-ethereum-account.react.js
+++ b/native/account/registration/existing-ethereum-account.react.js
@@ -4,10 +4,8 @@
import { Text, View } from 'react-native';
import { setDataLoadedActionType } from 'lib/actions/client-db-store-actions.js';
-import { legacySiweAuthActionTypes } from 'lib/actions/siwe-actions.js';
import { useENSName } from 'lib/hooks/ens-cache.js';
import { useWalletLogIn } from 'lib/hooks/login-hooks.js';
-import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors.js';
import type { SIWEResult } from 'lib/types/siwe-types.js';
import { useDispatch } from 'lib/utils/redux-utils.js';
import { usingCommServicesAccessToken } from 'lib/utils/services-utils.js';
@@ -18,16 +16,11 @@
import RegistrationContentContainer from './registration-content-container.react.js';
import type { RegistrationNavigationProp } from './registration-navigator.react.js';
import type { NavigationRoute } from '../../navigation/route-names.js';
-import { useSelector } from '../../redux/redux-utils.js';
import { useStyles } from '../../themes/colors.js';
import { UnknownErrorAlertDetails } from '../../utils/alert-messages.js';
import Alert from '../../utils/alert.js';
import { useLegacySIWEServerCall } from '../siwe-hooks.js';
-const legacySiweAuthLoadingStatusSelector = createLoadingStatusSelector(
- legacySiweAuthActionTypes,
-);
-
export type ExistingEthereumAccountParams = SIWEResult;
type Props = {
@@ -38,49 +31,41 @@
const legacySiweServerCall = useLegacySIWEServerCall();
const walletLogIn = useWalletLogIn();
+ const [logInPending, setLogInPending] = React.useState(false);
+
const { params } = props.route;
const dispatch = useDispatch();
const onProceedToLogIn = React.useCallback(async () => {
- if (usingCommServicesAccessToken) {
- try {
+ if (logInPending) {
+ return;
+ }
+ setLogInPending(true);
+ try {
+ if (usingCommServicesAccessToken) {
await walletLogIn(params.address, params.message, params.signature);
- } catch (e) {
- Alert.alert(
- UnknownErrorAlertDetails.title,
- UnknownErrorAlertDetails.message,
- [{ text: 'OK' }],
- {
- cancelable: false,
- },
- );
- throw e;
- }
- } else {
- try {
+ } else {
await legacySiweServerCall({ ...params, doNotRegister: true });
- } catch (e) {
- Alert.alert(
- UnknownErrorAlertDetails.title,
- UnknownErrorAlertDetails.message,
- [{ text: 'OK' }],
- {
- cancelable: false,
+ dispatch({
+ type: setDataLoadedActionType,
+ payload: {
+ dataLoaded: true,
},
- );
- throw e;
+ });
}
- dispatch({
- type: setDataLoadedActionType,
- payload: {
- dataLoaded: true,
+ } catch (e) {
+ Alert.alert(
+ UnknownErrorAlertDetails.title,
+ UnknownErrorAlertDetails.message,
+ [{ text: 'OK' }],
+ {
+ cancelable: false,
},
- });
+ );
+ throw e;
+ } finally {
+ setLogInPending(false);
}
- }, [legacySiweServerCall, walletLogIn, params, dispatch]);
-
- const legacySiweAuthCallLoading = useSelector(
- state => legacySiweAuthLoadingStatusSelector(state) === 'loading',
- );
+ }, [logInPending, legacySiweServerCall, walletLogIn, params, dispatch]);
const { address } = params;
const walletIdentifier = useENSName(address);
@@ -112,7 +97,7 @@
<RegistrationButton
onPress={onProceedToLogIn}
label="Log in to account"
- variant={legacySiweAuthCallLoading ? 'loading' : 'enabled'}
+ variant={logInPending ? 'loading' : 'enabled'}
/>
<RegistrationButton
onPress={goBack}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 8, 8:46 AM (1 h, 43 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2815717
Default Alt Text
D11807.diff (3 KB)
Attached To
Mode
D11807: [native] Fix pending state in ExistingEthereumAccount for identity auth
Attached
Detach File
Event Timeline
Log In to Comment