Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3253099
D6012.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
D6012.diff
View Options
diff --git a/landing/siwe.react.js b/landing/siwe.react.js
--- a/landing/siwe.react.js
+++ b/landing/siwe.react.js
@@ -5,6 +5,7 @@
getDefaultWallets,
RainbowKitProvider,
darkTheme,
+ useModalState,
} from '@rainbow-me/rainbowkit';
import invariant from 'invariant';
import _merge from 'lodash/fp/merge';
@@ -97,6 +98,16 @@
}
}, [hasNonce, openConnectModal]);
+ const prevConnectModalOpen = React.useRef(false);
+ const modalState = useModalState();
+ const { connectModalOpen } = modalState;
+ React.useEffect(() => {
+ if (!connectModalOpen && prevConnectModalOpen.current) {
+ postMessageToNativeWebView({ type: 'siwe_closed' });
+ }
+ prevConnectModalOpen.current = connectModalOpen;
+ }, [connectModalOpen]);
+
if (!hasNonce) {
return (
<div className={css.wrapper}>
diff --git a/lib/types/siwe-types.js b/lib/types/siwe-types.js
--- a/lib/types/siwe-types.js
+++ b/lib/types/siwe-types.js
@@ -7,9 +7,13 @@
// This is a message that the rendered webpage (landing/siwe.react.js) uses to
// communicate back to the React Native WebView that is rendering it
// (native/account/siwe-panel.react.js)
-export type SIWEWebViewMessage = {
- +type: 'siwe_success',
- +address: string,
- +message: string,
- +signature: string,
-};
+export type SIWEWebViewMessage =
+ | {
+ +type: 'siwe_success',
+ +address: string,
+ +message: string,
+ +signature: string,
+ }
+ | {
+ +type: 'siwe_closed',
+ };
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
@@ -82,6 +82,9 @@
},
[logInExtraInfo, dispatchActionPromise, registerAction],
);
+ const bottomSheetRef = React.useRef();
+ const closeBottomSheet = bottomSheetRef.current?.close;
+ const { onClose } = props;
const handleMessage = React.useCallback(
event => {
const data: SIWEWebViewMessage = JSON.parse(event.nativeEvent.data);
@@ -90,9 +93,12 @@
if (address && signature) {
handleSIWE({ address, signature });
}
+ } else if (data.type === 'siwe_closed') {
+ onClose();
+ closeBottomSheet?.();
}
},
- [handleSIWE],
+ [handleSIWE, onClose, closeBottomSheet],
);
const source = React.useMemo(
@@ -133,7 +139,6 @@
[],
);
- const { onClose } = props;
const onBottomSheetChange = React.useCallback(
(index: number) => {
if (index === -1) {
@@ -152,6 +157,7 @@
handleIndicatorStyle={bottomSheetHandleIndicatorStyle}
enablePanDownToClose={true}
onChange={onBottomSheetChange}
+ ref={bottomSheetRef}
>
<WebView
source={source}
diff --git a/patches/@rainbow-me+rainbowkit+0.5.3.patch b/patches/@rainbow-me+rainbowkit+0.5.3.patch
new file mode 100644
--- /dev/null
+++ b/patches/@rainbow-me+rainbowkit+0.5.3.patch
@@ -0,0 +1,34 @@
+diff --git a/node_modules/@rainbow-me/rainbowkit/dist/chunk-R7UVC5N6.js b/node_modules/@rainbow-me/rainbowkit/dist/chunk-R7UVC5N6.js
+index 275c804..ca20931 100644
+--- a/node_modules/@rainbow-me/rainbowkit/dist/chunk-R7UVC5N6.js
++++ b/node_modules/@rainbow-me/rainbowkit/dist/chunk-R7UVC5N6.js
+@@ -4590,5 +4590,6 @@ export {
+ useAccountModal,
+ useChainModal,
+ useConnectModal,
+- ConnectButton
++ ConnectButton,
++ useModalState,
+ };
+diff --git a/node_modules/@rainbow-me/rainbowkit/dist/index.js b/node_modules/@rainbow-me/rainbowkit/dist/index.js
+index 8630ea1..a6fac1c 100644
+--- a/node_modules/@rainbow-me/rainbowkit/dist/index.js
++++ b/node_modules/@rainbow-me/rainbowkit/dist/index.js
+@@ -22,7 +22,8 @@ import {
+ useChainId,
+ useChainModal,
+ useConnectModal,
+- useTransactionStore
++ useTransactionStore,
++ useModalState,
+ } from "./chunk-R7UVC5N6.js";
+ import {
+ lightTheme
+@@ -701,5 +702,6 @@ export {
+ useAddRecentTransaction,
+ useChainModal,
+ useConnectModal,
+- wallet
++ wallet,
++ useModalState,
+ };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 16, 6:45 PM (21 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2500793
Default Alt Text
D6012.diff (3 KB)
Attached To
Mode
D6012: [native][landing] Close SIWEPanel when close button in WebView pressed
Attached
Detach File
Event Timeline
Log In to Comment