File size: 1,120 Bytes
dc06ee7
3578090
506c5f2
 
3578090
5856d68
506c5f2
3578090
dc06ee7
 
3578090
506c5f2
3578090
 
 
506c5f2
 
 
 
 
3578090
 
 
 
506c5f2
5856d68
dc06ee7
5856d68
506c5f2
dc06ee7
 
506c5f2
3578090
dc06ee7
 
 
 
93e01b6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import ThemeProvider from '@/components/ThemeProvider'
import MessageAlert from '@/components/MessageAlert'
import StatusIndicator from '@/components/StatusIndicator'
import GraphViewer from '@/GraphViewer'
import { healthCheckInterval } from '@/lib/constants'
import { useBackendState } from '@/stores/state'
import { useSettingsStore } from '@/stores/settings'
import { useEffect } from 'react'

function App() {
  const message = useBackendState.use.message()
  const enableHealthCheck = useSettingsStore.use.enableHealthCheck()

  // health check
  useEffect(() => {
    if (!enableHealthCheck) return

    // Check immediately
    useBackendState.getState().check()

    const interval = setInterval(async () => {
      await useBackendState.getState().check()
    }, healthCheckInterval * 1000)
    return () => clearInterval(interval)
  }, [enableHealthCheck])

  return (
    <ThemeProvider>
      <div className="h-screen w-screen">
        <GraphViewer />
      </div>
      {enableHealthCheck && <StatusIndicator />}
      {message !== null && <MessageAlert />}
    </ThemeProvider>
  )
}

export default App