@@ -53,10 +53,8 @@ const ElectionShow: FC = () => {
53
53
54
54
// called by a DKG row
55
55
const notifyDKGState = ( node : string , info : InternalDKGInfo ) => {
56
- console . log ( 'DKG node updated:' , info ) ;
57
56
switch ( info . getStatus ( ) ) {
58
57
case NodeStatus . Failed :
59
- console . log ( 'DKG node failed' ) ;
60
58
setOngoingAction ( OngoingAction . None ) ;
61
59
break ;
62
60
case NodeStatus . Setup :
@@ -68,7 +66,6 @@ const ElectionShow: FC = () => {
68
66
const newDKGStatuses = new Map ( DKGStatuses ) ;
69
67
newDKGStatuses . set ( node , info . getStatus ( ) ) ;
70
68
setDKGStatuses ( newDKGStatuses ) ;
71
- console . log ( 'dkg statuses:' , DKGStatuses ) ;
72
69
} ;
73
70
74
71
// called by a DKG row
@@ -103,7 +100,6 @@ const ElectionShow: FC = () => {
103
100
const storedOngoingAction = JSON . parse ( window . localStorage . getItem ( ongoingItem ) ) ;
104
101
105
102
if ( storedOngoingAction !== null ) {
106
- console . log ( 'stored ongoing action:' , storedOngoingAction ) ;
107
103
setOngoingAction ( storedOngoingAction ) ;
108
104
}
109
105
@@ -152,10 +148,14 @@ const ElectionShow: FC = () => {
152
148
// eslint-disable-next-line react-hooks/exhaustive-deps
153
149
} , [ roster ] ) ;
154
150
151
+ // Keep the "DKGLoading" state according to "nodeLoading". This state tells if
152
+ // one of the element on the map is true.
155
153
useEffect ( ( ) => {
156
154
if ( nodeLoading !== null ) {
157
155
if ( ! Array . from ( nodeLoading . values ( ) ) . includes ( true ) ) {
158
156
setDKGLoading ( false ) ;
157
+ } else {
158
+ setDKGLoading ( true ) ;
159
159
}
160
160
}
161
161
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -166,24 +166,18 @@ const ElectionShow: FC = () => {
166
166
if ( status === Status . Initial ) {
167
167
if ( DKGStatuses !== null && ! DKGLoading ) {
168
168
const statuses = Array . from ( DKGStatuses . values ( ) ) ;
169
+ setOngoingAction ( OngoingAction . None ) ;
169
170
170
171
// TODO: can be modified such that if the majority of the node are
171
172
// initialized than the election status can still be set to initialized
172
- if ( statuses . includes ( NodeStatus . NotInitialized ) ) {
173
- setOngoingAction ( OngoingAction . None ) ;
174
- setStatus ( Status . Initial ) ;
173
+ if (
174
+ statuses . includes ( NodeStatus . NotInitialized ) ||
175
+ statuses . includes ( NodeStatus . Unreachable ) ||
176
+ statuses . includes ( NodeStatus . Failed )
177
+ ) {
175
178
return ;
176
179
}
177
180
178
- if ( statuses . includes ( NodeStatus . Setup ) ) {
179
- setOngoingAction ( OngoingAction . None ) ;
180
- setStatus ( Status . Setup ) ;
181
- return ;
182
- }
183
-
184
- if ( statuses . includes ( NodeStatus . Unreachable ) ) return ;
185
- if ( statuses . includes ( NodeStatus . Failed ) ) return ;
186
-
187
181
setStatus ( Status . Initialized ) ;
188
182
189
183
// Status Failed is handled by useChangeAction
0 commit comments