mirror of
https://github.com/mosip/inji-wallet.git
synced 2026-01-09 05:27:57 -05:00
Injimob-3649: add delay before rendering WebView to prevent missing authorize call on Android BrowserStack (#2148)
* [INJIMOB-3649]: need INJI Mobile APK with network logs enabled Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3649]: add delay before loading WebView to prevent eSignet auth page not rendering on BrowserStack Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3649]: fix WebView initialization issue on Android BrowserStack Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3649]: remove the delay completely Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3649]: clear coderabbit review comments Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3649]: clear review comments Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3649]: clear coderabbit review comments Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> --------- Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com>
This commit is contained in:
@@ -14,12 +14,15 @@ import {Ionicons} from '@expo/vector-icons';
|
||||
import VciClient from '../shared/vciClient/VciClient';
|
||||
import {Theme} from '../components/ui/styleUtils';
|
||||
import {useTranslation} from 'react-i18next';
|
||||
import {isAndroid} from '../shared/constants';
|
||||
|
||||
const AuthWebViewScreen: React.FC<any> = ({route, navigation}) => {
|
||||
const {authorizationURL, clientId, redirectUri, controller} = route.params;
|
||||
const webViewRef = useRef<WebView>(null);
|
||||
const [showWebView, setShowWebView] = useState(false);
|
||||
const [shouldRenderWebView, setShouldRenderWebView] = useState(false);
|
||||
const {t} = useTranslation('authWebView');
|
||||
const WEBVIEW_INIT_DELAY_MS = 300;
|
||||
|
||||
const hostName = new URL(authorizationURL).hostname; // example.mosip.net
|
||||
const parsed = psl.parse(hostName);
|
||||
@@ -74,6 +77,22 @@ const AuthWebViewScreen: React.FC<any> = ({route, navigation}) => {
|
||||
handleBackPress,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
let timeoutId: NodeJS.Timeout | null = null;
|
||||
|
||||
if (isAndroid()) {
|
||||
setShouldRenderWebView(true);
|
||||
|
||||
timeoutId = setTimeout(() => {
|
||||
setShouldRenderWebView(false);
|
||||
}, WEBVIEW_INIT_DELAY_MS);
|
||||
}
|
||||
|
||||
return () => {
|
||||
if (timeoutId) clearTimeout(timeoutId);
|
||||
};
|
||||
}, []);
|
||||
|
||||
const handleNavigationRequest = (request: any) => {
|
||||
const {url} = request;
|
||||
if (url.startsWith(redirectUri)) {
|
||||
@@ -118,6 +137,9 @@ const AuthWebViewScreen: React.FC<any> = ({route, navigation}) => {
|
||||
return (
|
||||
<SafeAreaView style={{flex: 1}}>
|
||||
<Header />
|
||||
{shouldRenderWebView && !showWebView && (
|
||||
<WebView style={{width: 0, height: 0}} source={{uri: 'about:blank'}} />
|
||||
)}
|
||||
{showWebView && (
|
||||
<WebView
|
||||
ref={webViewRef}
|
||||
|
||||
Reference in New Issue
Block a user