Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3389556
D7928.id26818.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D7928.id26818.diff
View Options
diff --git a/native/account/fullscreen-siwe-panel.react.js b/native/account/fullscreen-siwe-panel.react.js
--- a/native/account/fullscreen-siwe-panel.react.js
+++ b/native/account/fullscreen-siwe-panel.react.js
@@ -3,6 +3,8 @@
import * as React from 'react';
import { Alert, ActivityIndicator, View } from 'react-native';
+import type { SIWEResult } from 'lib/types/siwe-types.js';
+
import { useSIWEServerCall } from './siwe-hooks.js';
import SIWEPanel from './siwe-panel.react.js';
@@ -22,20 +24,35 @@
[],
);
- const { onClose } = props;
+ const onCloseProp = props.onClose;
const siweServerCallParams = React.useMemo(() => {
const onServerCallFailure = () => {
Alert.alert(
'Unknown error',
'Uhh... try again?',
- [{ text: 'OK', onPress: onClose }],
+ [{ text: 'OK', onPress: onCloseProp }],
{ cancelable: false },
);
};
return { onFailure: onServerCallFailure };
- }, [onClose]);
+ }, [onCloseProp]);
const siweServerCall = useSIWEServerCall(siweServerCallParams);
+ const successRef = React.useRef(false);
+ const onSuccess = React.useCallback(
+ (result: SIWEResult) => {
+ successRef.current = true;
+ return siweServerCall(result);
+ },
+ [siweServerCall],
+ );
+
+ const onClose = React.useCallback(() => {
+ if (!successRef.current) {
+ onCloseProp();
+ }
+ }, [onCloseProp]);
+
const { closing } = props;
return (
<>
@@ -44,7 +61,7 @@
closing={closing}
onClosed={onClose}
onClosing={onClose}
- onSuccessfulWalletSignature={siweServerCall}
+ onSuccessfulWalletSignature={onSuccess}
setLoading={setLoading}
/>
</>
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
@@ -107,14 +107,12 @@
const closeBottomSheet = bottomSheetRef.current?.close;
const { closing, onSuccessfulWalletSignature } = props;
- const disableOnClose = React.useRef(false);
const handleMessage = React.useCallback(
async event => {
const data: SIWEWebViewMessage = JSON.parse(event.nativeEvent.data);
if (data.type === 'siwe_success') {
const { address, message, signature } = data;
if (address && signature) {
- disableOnClose.current = true;
closeBottomSheet?.();
await onSuccessfulWalletSignature({ address, message, signature });
}
@@ -167,10 +165,6 @@
const { onClosed } = props;
const onBottomSheetChange = React.useCallback(
(index: number) => {
- if (disableOnClose.current) {
- disableOnClose.current = false;
- return;
- }
if (index === -1) {
onClosed();
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 30, 7:37 PM (20 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2602147
Default Alt Text
D7928.id26818.diff (2 KB)
Attached To
Mode
D7928: [native] Extract onClose-disabling behavior from SIWEPanel to FullscreenSIWEPanel
Attached
Detach File
Event Timeline
Log In to Comment