@@ -17,19 +17,33 @@ const log = uiLogger.forComponent('redirect-page')
17
17
18
18
const ConfigIframe : React . FC = ( ) => {
19
19
const { parentDomain } = getSubdomainParts ( window . location . href )
20
+ const { isServiceWorkerRegistered } = useContext ( ServiceWorkerContext )
21
+
20
22
let iframeSrc
21
23
if ( parentDomain == null || parentDomain === window . location . href ) {
22
24
const url = new URL ( window . location . href )
23
25
url . pathname = '/'
24
26
url . hash = `#/ipfs-sw-config@origin=${ encodeURIComponent ( window . location . origin ) } `
27
+
25
28
iframeSrc = url . href
26
29
} else {
27
30
const portString = window . location . port === '' ? '' : `:${ window . location . port } `
28
31
iframeSrc = `${ window . location . protocol } //${ parentDomain } ${ portString } /#/ipfs-sw-config@origin=${ encodeURIComponent ( window . location . origin ) } `
29
32
}
30
33
34
+ const [ isVisible , setIsVisible ] = useState ( false )
35
+
36
+ useEffect ( ( ) => {
37
+ // Only show iframe after service worker is registered
38
+ if ( isServiceWorkerRegistered ) {
39
+ setIsVisible ( true )
40
+ }
41
+ } , [ isServiceWorkerRegistered ] )
42
+
31
43
return (
32
- < iframe id = "redirect-config-iframe" src = { iframeSrc } style = { { width : '100vw' , height : '100vh' , border : 'none' } } />
44
+ < div style = { { display : isVisible ? 'block' : 'none' } } >
45
+ < iframe id = "redirect-config-iframe" src = { iframeSrc } style = { { width : '100vw' , height : '100vh' , border : 'none' } } />
46
+ </ div >
33
47
)
34
48
}
35
49
@@ -38,6 +52,7 @@ function RedirectPage ({ showConfigIframe = true }: { showConfigIframe?: boolean
38
52
const { isServiceWorkerRegistered } = useContext ( ServiceWorkerContext )
39
53
const [ reloadUrl , setReloadUrl ] = useState ( translateIpfsRedirectUrl ( window . location . href ) . href )
40
54
const [ isLoadingContent , setIsLoadingContent ] = useState ( false )
55
+ const [ isConfigLoading , setIsConfigLoading ] = useState ( true )
41
56
42
57
useEffect ( ( ) => {
43
58
if ( isConfigPage ( window . location . hash ) ) {
@@ -60,6 +75,7 @@ function RedirectPage ({ showConfigIframe = true }: { showConfigIframe?: boolean
60
75
if ( config != null ) {
61
76
void doWork ( config as ConfigDb )
62
77
}
78
+ setIsConfigLoading ( false )
63
79
}
64
80
}
65
81
window . addEventListener ( 'message' , listener )
@@ -90,7 +106,7 @@ function RedirectPage ({ showConfigIframe = true }: { showConfigIframe?: boolean
90
106
}
91
107
} , [ isAutoReloadEnabled , isServiceWorkerRegistered , loadContent ] )
92
108
93
- if ( isLoadingContent ) {
109
+ if ( isLoadingContent || isConfigLoading ) {
94
110
return < LoadingPage />
95
111
}
96
112
0 commit comments