From 31e344f3586a853a2147bc0341787c789114cd52 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Wed, 13 Mar 2024 17:43:38 +0100 Subject: [PATCH] Retry to check if external script is binded --- src/dashboardWebView/components/App.tsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/dashboardWebView/components/App.tsx b/src/dashboardWebView/components/App.tsx index c0f14260..51b2b50a 100644 --- a/src/dashboardWebView/components/App.tsx +++ b/src/dashboardWebView/components/App.tsx @@ -55,6 +55,21 @@ export const App: React.FunctionComponent = ({ return isAllowed(mode?.features || [], FEATURE_FLAG.dashboard.taxonomy.view); }, [mode?.features]); + const checkDevMode = (retry: number = 0) => { + if (!window.fmExternal) { + if (retry < 5) { + setTimeout(() => checkDevMode(retry + 1), 150); + } else { + setIsDevMode(false); + return; + } + } + + if (window.fmExternal && window.fmExternal.isDevelopment) { + setIsDevMode(true); + } + } + useEffect(() => { if (view && routePaths[view]) { navigate(routePaths[view]); @@ -65,9 +80,7 @@ export const App: React.FunctionComponent = ({ }, [view]); useEffect(() => { - if (window.fmExternal && window.fmExternal.isDevelopment) { - setIsDevMode(true); - } + checkDevMode(); }, []); if (!settings) {