diff --git a/src/components/webviews/CryptoWebView/CryptoWebView.js b/src/components/webviews/CryptoWebView/CryptoWebView.js index 73b399bbe..9c00ba099 100644 --- a/src/components/webviews/CryptoWebView/CryptoWebView.js +++ b/src/components/webviews/CryptoWebView/CryptoWebView.js @@ -33,6 +33,12 @@ export const CryptoWebView = ({ setHasCrypto }) => { const processAnswer = event => { const webviewAnswer = JSON.parse(event.nativeEvent.data) + if (webviewAnswer.isReady) { + log.debug('Ready') + setIsLoading(false) + return + } + if (webviewAnswer.isError) { log.error(`Error : ${event.nativeEvent.data}`) return @@ -61,7 +67,6 @@ export const CryptoWebView = ({ setHasCrypto }) => { ref={webviewRef} javaScriptEnabled={true} onMessage={processAnswer} - onLoadEnd={() => setIsLoading(false)} originWhitelist={['*']} source={{ html, baseUrl: 'https://localhost' }} supervisionShowProgress={false} diff --git a/src/components/webviews/CryptoWebView/CryptoWebView.spec.js b/src/components/webviews/CryptoWebView/CryptoWebView.spec.js index 0aacc6e2a..425c090b5 100644 --- a/src/components/webviews/CryptoWebView/CryptoWebView.spec.js +++ b/src/components/webviews/CryptoWebView/CryptoWebView.spec.js @@ -35,7 +35,13 @@ jest.mock('react-native-webview', () => { }) } componentDidMount() { - this.props.onLoadEnd() + this.props.onMessage({ + nativeEvent: { + data: JSON.stringify({ + isReady: true + }) + } + }) } render() { return
WebView
diff --git a/src/components/webviews/CryptoWebView/jsInteractions/jsCryptoInjection.js b/src/components/webviews/CryptoWebView/jsInteractions/jsCryptoInjection.js index 4a666acbb..ed6e56f1a 100644 --- a/src/components/webviews/CryptoWebView/jsInteractions/jsCryptoInjection.js +++ b/src/components/webviews/CryptoWebView/jsInteractions/jsCryptoInjection.js @@ -23,6 +23,8 @@ const jsCode = ` generateHttpServerSecurityKey, sublteProxy } + + postMessage(JSON.stringify({ isReady: true })) ` export const html = `