File tree 1 file changed +22
-5
lines changed
web-app/src/containers/Loading
1 file changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import Message from '../../components/Message'
6
6
7
7
interface Props {
8
8
text : string
9
- context : T . MachineContext
9
+ context ? : T . MachineContext
10
10
}
11
11
12
12
const styles = {
@@ -16,19 +16,36 @@ const styles = {
16
16
flexDirection : 'column' as 'column' ,
17
17
alignItems : 'center' ,
18
18
justifyContent : 'center' ,
19
- width : '100%' ,
19
+ height : '100%' ,
20
20
} ,
21
21
}
22
22
23
23
const LoadingPage = ( { text, context } : Props ) => {
24
- const { error } = context
25
- if ( error ) {
24
+ const [ showLoading , setShowHiding ] = React . useState ( false )
25
+
26
+ React . useEffect ( ( ) => {
27
+ // wait some time before showing loading indicator
28
+ const timeout = setTimeout ( ( ) => {
29
+ setShowHiding ( true )
30
+ } , 600 )
31
+ return ( ) => {
32
+ clearTimeout ( timeout )
33
+ }
34
+ } , [ ] )
35
+
36
+ if ( context && context . error ) {
26
37
return (
27
38
< div css = { styles . page } >
28
- < Message type = "error" title = { error . title } content = { error . description } />
39
+ < Message type = "error" title = { context . error . title } content = { context . error . description } />
29
40
</ div >
30
41
)
31
42
}
43
+
44
+ // don't flash loader
45
+ if ( ! showLoading ) {
46
+ return null
47
+ }
48
+
32
49
return (
33
50
< div css = { styles . page } >
34
51
< Loading text = { text } />
You can’t perform that action at this time.
0 commit comments