Fix error when using build files
This commit is contained in:
parent
d0623be1c3
commit
b1cc35d4e0
@ -1,4 +1,4 @@
|
||||
import { useEffect, useCallback } from 'react';
|
||||
import { useEffect, useCallback, useState } from 'react';
|
||||
import { useNavigation } from '@react-navigation/native';
|
||||
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
||||
|
||||
@ -8,6 +8,9 @@ import { StackParamsList } from '../types';
|
||||
import useGetOrCreateAccounts from './useGetOrCreateAccounts';
|
||||
|
||||
export const useWebViewHandler = () => {
|
||||
const [isReady, setIsReady] = useState(false);
|
||||
useGetOrCreateAccounts();
|
||||
|
||||
// Navigation and context hooks
|
||||
const navigation = useNavigation<NativeStackNavigationProp<StackParamsList>>();
|
||||
const { selectedNetwork } = useNetworks();
|
||||
@ -19,6 +22,13 @@ export const useWebViewHandler = () => {
|
||||
// Core navigation handler
|
||||
const navigateToSignRequest = useCallback((message: string) => {
|
||||
try {
|
||||
// Wait for accounts to be ready
|
||||
if (!isReady) {
|
||||
console.log('Accounts not yet ready');
|
||||
window.Android?.onSignatureError?.('Accounts not yet ready');
|
||||
return;
|
||||
}
|
||||
|
||||
// Validation checks
|
||||
if (!selectedNetwork?.namespace || !selectedNetwork?.chainId) {
|
||||
window.Android?.onSignatureError?.('Invalid network configuration');
|
||||
@ -68,7 +78,7 @@ export const useWebViewHandler = () => {
|
||||
} catch (error) {
|
||||
window.Android?.onSignatureError?.(`Navigation error: ${error}`);
|
||||
}
|
||||
}, [selectedNetwork, accounts, currentIndex, navigation]);
|
||||
}, [selectedNetwork, accounts, currentIndex, navigation, isReady]);
|
||||
|
||||
useEffect(() => {
|
||||
// Assign the function to the window object
|
||||
|
Loading…
Reference in New Issue
Block a user