@@ -39,11 +39,15 @@ export default function EditorTime() {
39
39
const { project_id, path, actions } = useFrameContext ( ) as unknown as {
40
40
project_id : string ;
41
41
path : string ;
42
- actions : TimeActions ;
42
+ actions ? : TimeActions ;
43
43
} ;
44
44
const timers : List < any > | undefined = useRedux ( [ "timers" ] , project_id , path ) ;
45
45
const error : string | undefined = useRedux ( [ "error" ] , project_id , path ) ;
46
46
47
+ if ( timers == null || actions == null ) {
48
+ return < Loading /> ;
49
+ }
50
+
47
51
function renderStopwatches ( ) : ReactNode [ ] {
48
52
if ( timers == null ) {
49
53
return [ ] ;
@@ -64,7 +68,7 @@ export default function EditorTime() {
64
68
setCountdown = {
65
69
data . countdown != null
66
70
? ( countdown ) => {
67
- actions . setCountdown ( data . id , countdown ) ;
71
+ actions ? .setCountdown ( data . id , countdown ) ;
68
72
}
69
73
: undefined
70
74
}
@@ -73,6 +77,9 @@ export default function EditorTime() {
73
77
}
74
78
75
79
function clickButton ( id : number , button : string ) : void {
80
+ if ( actions == null ) {
81
+ return ;
82
+ }
76
83
switch ( button ) {
77
84
case "reset" :
78
85
actions . resetStopwatch ( id ) ;
@@ -93,14 +100,14 @@ export default function EditorTime() {
93
100
}
94
101
95
102
function setLabel ( id : number , label : string ) : void {
96
- actions . setLabel ( id , label ) ;
103
+ actions ? .setLabel ( id , label ) ;
97
104
}
98
105
99
106
function renderButtonBar ( ) : ReactNode {
107
+ if ( actions == null ) return null ;
100
108
return < ButtonBar actions = { actions } /> ;
101
109
}
102
110
103
- if ( timers == null ) return < Loading /> ;
104
111
return (
105
112
< div className = "smc-vfill" >
106
113
{ error && < Alert type = "error" message = { `Error: ${ error } ` } /> }
0 commit comments