@@ -16,7 +16,7 @@ const context = {
1616}
1717
1818function useClusterStatus ( props ) {
19- const [ { cstat, user, eventSourceAlive} , dispatch ] = useStateValue ( )
19+ const [ { cstat, user, eventSourceAlive, authenticated } , dispatch ] = useStateValue ( )
2020 const { auth } = useUser ( )
2121 const lastDispatch = useRef ( Date . now ( ) )
2222 const limit = 1000
@@ -36,6 +36,7 @@ function useClusterStatus(props) {
3636 }
3737
3838 function initEventSource ( ) {
39+ if ( ! authenticated ) { return ; }
3940 if ( context . eventSource !== null && context . eventSource . readyState != 2 ) {
4041 return
4142 }
@@ -98,6 +99,7 @@ function useClusterStatus(props) {
9899 }
99100
100101 async function loadCstat ( ) {
102+ if ( ! authenticated ) { return ; }
101103 if ( ! hasAuthorizationHeader ( auth ) ) {
102104 console . log ( "loadCstat" , false , auth )
103105 return
@@ -151,20 +153,22 @@ function useClusterStatus(props) {
151153 }
152154
153155 function init ( ) {
154- if ( ! context . cstat ) {
156+ if ( ! authenticated ) { return }
157+ if ( ! context . cstat ) {
155158 loadCstat ( )
156159 }
157160 initEventSource ( )
158161 }
159162
160163 useEffect ( ( ) => {
161- if ( ! context . auth || ( context . auth . access_token == auth . access_token ) && ( context . auth . username == auth . username ) ) {
164+ if ( ! authenticated ) { return }
165+ if ( ! context . auth || ( context . auth . access_token == auth . access_token ) && ( context . auth . username == auth . username ) ) {
162166 init ( )
163167 } else {
164168 reset ( )
165169 }
166170 context . auth = auth
167- } , [ ] )
171+ } , [ authenticated ] )
168172
169173 return {
170174 cstat : cstat ,
0 commit comments