Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3389558
D12032.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D12032.diff
View Options
diff --git a/native/account/registration/connect-ethereum.react.js b/native/account/registration/connect-ethereum.react.js
--- a/native/account/registration/connect-ethereum.react.js
+++ b/native/account/registration/connect-ethereum.react.js
@@ -36,6 +36,7 @@
import { useStyles } from '../../themes/colors.js';
import { defaultURLPrefix } from '../../utils/url-utils.js';
import EthereumLogoDark from '../../vectors/ethereum-logo-dark.react.js';
+import { useSIWEPanelState } from '../siwe-hooks.js';
import SIWEPanel from '../siwe-panel.react.js';
const exactSearchUserLoadingStatusSelector = createLoadingStatusSelector(
@@ -50,8 +51,6 @@
},
};
-type PanelState = 'closed' | 'opening' | 'open' | 'closing';
-
type Props = {
+navigation: RegistrationNavigationProp<'ConnectEthereum'>,
+route: NavigationRoute<'ConnectEthereum'>,
@@ -108,27 +107,6 @@
);
}
- const [panelState, setPanelState] = React.useState<PanelState>('closed');
- const openPanel = React.useCallback(() => {
- setPanelState('opening');
- }, []);
- const onPanelClosed = React.useCallback(() => {
- setPanelState('closed');
- }, []);
- const onPanelClosing = React.useCallback(() => {
- setPanelState('closing');
- }, []);
-
- const siwePanelSetLoading = React.useCallback(
- (loading: boolean) => {
- if (panelState === 'closing' || panelState === 'closed') {
- return;
- }
- setPanelState(loading ? 'opening' : 'open');
- },
- [panelState],
- );
-
const { navigate } = props.navigation;
const onSkip = React.useCallback(() => {
navigate<'UsernameSelection'>({
@@ -202,6 +180,14 @@
],
);
+ const {
+ panelState,
+ onPanelClosed,
+ onPanelClosing,
+ siwePanelSetLoading,
+ openPanel,
+ } = useSIWEPanelState();
+
let siwePanel;
if (panelState !== 'closed') {
siwePanel = (
diff --git a/native/account/registration/siwe-backup-message-creation.react.js b/native/account/registration/siwe-backup-message-creation.react.js
--- a/native/account/registration/siwe-backup-message-creation.react.js
+++ b/native/account/registration/siwe-backup-message-creation.react.js
@@ -24,10 +24,9 @@
} from '../../navigation/route-names.js';
import { useStyles } from '../../themes/colors.js';
import Alert from '../../utils/alert.js';
+import { useSIWEPanelState } from '../siwe-hooks.js';
import SIWEPanel from '../siwe-panel.react.js';
-type PanelState = 'closed' | 'opening' | 'open' | 'closing';
-
type CreateSIWEBackupMessageBaseProps = {
+onSuccessfulWalletSignature: (result: SIWEResult) => void,
+onExistingWalletSignature?: () => void,
@@ -43,27 +42,13 @@
props;
const styles = useStyles(unboundStyles);
- const [panelState, setPanelState] = React.useState<PanelState>('closed');
-
- const openPanel = React.useCallback(() => {
- setPanelState('opening');
- }, []);
- const onPanelClosed = React.useCallback(() => {
- setPanelState('closed');
- }, []);
- const onPanelClosing = React.useCallback(() => {
- setPanelState('closing');
- }, []);
-
- const siwePanelSetLoading = React.useCallback(
- (loading: boolean) => {
- if (panelState === 'closing' || panelState === 'closed') {
- return;
- }
- setPanelState(loading ? 'opening' : 'open');
- },
- [panelState],
- );
+ const {
+ panelState,
+ onPanelClosed,
+ onPanelClosing,
+ openPanel,
+ siwePanelSetLoading,
+ } = useSIWEPanelState();
let siwePanel;
if (panelState !== 'closed') {
diff --git a/native/account/siwe-hooks.js b/native/account/siwe-hooks.js
--- a/native/account/siwe-hooks.js
+++ b/native/account/siwe-hooks.js
@@ -124,4 +124,52 @@
);
}
-export { useLegacySIWEServerCall, useIdentityWalletRegisterCall };
+type PanelState = 'closed' | 'opening' | 'open' | 'closing';
+
+function useSIWEPanelState(): {
+ +panelState: PanelState,
+ +openPanel: () => void,
+ +onPanelClosed: () => void,
+ +onPanelClosing: () => void,
+ +siwePanelSetLoading: (loading: boolean) => void,
+} {
+ const [panelState, setPanelState] = React.useState<PanelState>('closed');
+
+ const openPanel = React.useCallback(() => {
+ setPanelState('opening');
+ }, []);
+
+ const onPanelClosed = React.useCallback(() => {
+ setPanelState('closed');
+ }, []);
+ const onPanelClosing = React.useCallback(() => {
+ setPanelState('closing');
+ }, []);
+
+ const siwePanelSetLoading = React.useCallback(
+ (loading: boolean) => {
+ if (panelState === 'closing' || panelState === 'closed') {
+ return;
+ }
+ setPanelState(loading ? 'opening' : 'open');
+ },
+ [panelState],
+ );
+
+ return React.useMemo(
+ () => ({
+ panelState,
+ openPanel,
+ onPanelClosed,
+ onPanelClosing,
+ siwePanelSetLoading,
+ }),
+ [panelState, openPanel, onPanelClosed, onPanelClosing, siwePanelSetLoading],
+ );
+}
+
+export {
+ useLegacySIWEServerCall,
+ useIdentityWalletRegisterCall,
+ useSIWEPanelState,
+};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 30, 7:37 PM (22 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2602148
Default Alt Text
D12032.diff (5 KB)
Attached To
Mode
D12032: Extract shared logci for SIWE panel state handling
Attached
Detach File
Event Timeline
Log In to Comment