Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3339255
D13772.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
D13772.diff
View Options
diff --git a/native/account/siwe-panel.react.js b/native/account/siwe-panel.react.js
--- a/native/account/siwe-panel.react.js
+++ b/native/account/siwe-panel.react.js
@@ -91,6 +91,17 @@
// to be unmounted/remounted by our parent component prior to a retry
const nonceNotNeededRef = React.useRef(false);
+ // When we succeed or fail, we call onSuccessOrCancel, which cancels
+ // any pending setWalletConnectModalHeight callbacks
+ const walletConnectModalHeightResetTimeout = React.useRef<?TimeoutID>();
+ const onSuccessOrCancel = React.useCallback(() => {
+ nonceNotNeededRef.current = true;
+ if (walletConnectModalHeightResetTimeout.current) {
+ clearTimeout(walletConnectModalHeightResetTimeout.current);
+ walletConnectModalHeightResetTimeout.current = undefined;
+ }
+ }, []);
+
React.useEffect(() => {
if (siweNonce && siweStatement && siweIssuedAt) {
setNonceInfo({
@@ -101,7 +112,7 @@
const siwePrimaryIdentityPublicKey =
getPublicKeyFromSIWEStatement(siweStatement);
setPrimaryIdentityPublicKey(siwePrimaryIdentityPublicKey);
- nonceNotNeededRef.current = true;
+ onSuccessOrCancel();
return;
}
if (nonceNotNeededRef.current) {
@@ -123,7 +134,7 @@
{
text: 'OK',
onPress: () => {
- nonceNotNeededRef.current = true;
+ onSuccessOrCancel();
onClosing();
},
},
@@ -158,6 +169,7 @@
siweNonce,
siweStatement,
siweIssuedAt,
+ onSuccessOrCancel,
]);
const [isLoading, setLoading] = React.useState(true);
@@ -200,7 +212,7 @@
if (data.type === 'siwe_success') {
const { address, message, signature } = data;
if (address && signature) {
- nonceNotNeededRef.current = true;
+ onSuccessOrCancel();
closeBottomSheet?.();
await onSuccessfulWalletSignature({
address,
@@ -210,14 +222,23 @@
});
}
} else if (data.type === 'siwe_closed') {
- nonceNotNeededRef.current = true;
+ onSuccessOrCancel();
onClosing();
closeBottomSheet?.();
} else if (data.type === 'walletconnect_modal_update') {
+ if (nonceNotNeededRef.current) {
+ return;
+ }
const height = data.state === 'open' ? data.height : 0;
if (!walletConnectModalHeight || height > 0) {
setWalletConnectModalHeight(height);
+ return;
}
+ walletConnectModalHeightResetTimeout.current = setTimeout(() => {
+ if (!nonceNotNeededRef.current) {
+ setWalletConnectModalHeight(height);
+ }
+ }, 50);
}
},
[
@@ -226,16 +247,17 @@
closeBottomSheet,
walletConnectModalHeight,
nonceTimestamp,
+ onSuccessOrCancel,
],
);
const prevClosingRef = React.useRef<?boolean>();
React.useEffect(() => {
if (closing && !prevClosingRef.current) {
- nonceNotNeededRef.current = true;
+ onSuccessOrCancel();
closeBottomSheet?.();
}
prevClosingRef.current = closing;
- }, [closing, closeBottomSheet]);
+ }, [closing, closeBottomSheet, onSuccessOrCancel]);
const nonce = nonceInfo?.nonce;
const issuedAt = nonceInfo?.issuedAt;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 22, 7:23 PM (18 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2564359
Default Alt Text
D13772.diff (3 KB)
Attached To
Mode
D13772: [native] Resize back after WalletConnect modal closes
Attached
Detach File
Event Timeline
Log In to Comment