@@ -72,7 +72,8 @@ const createDefaultChart = (ctx: CanvasRenderingContext2D, options?: ChartConfig
7272} ) ;
7373
7474export default ( ) => {
75- const { limits } = ServerContext . useStoreState ( state => state . server . data ! ) ;
75+ const status = ServerContext . useStoreState ( state => state . status . value ) ;
76+ const limits = ServerContext . useStoreState ( state => state . server . data ! . limits ) ;
7677 const { connected, instance } = ServerContext . useStoreState ( state => state . socket ) ;
7778
7879 const [ memory , setMemory ] = useState < Chart > ( ) ;
@@ -152,15 +153,28 @@ export default () => {
152153 return ( ) => {
153154 instance . removeListener ( 'stats' , statsListener ) ;
154155 } ;
155- } , [ connected , memory , cpu ] ) ;
156+ // eslint-disable-next-line react-hooks/exhaustive-deps
157+ } , [ instance , connected , memory , cpu ] ) ;
156158
157159 return (
158160 < div className = { 'flex mt-4' } >
159161 < TitledGreyBox title = { 'Memory usage' } icon = { faMemory } className = { 'flex-1 mr-2' } >
160- < canvas id = { 'memory_chart' } ref = { memoryRef } aria-label = { 'Server Memory Usage Graph' } role = { 'img' } />
162+ { status !== 'offline' ?
163+ < canvas id = { 'memory_chart' } ref = { memoryRef } aria-label = { 'Server Memory Usage Graph' } role = { 'img' } />
164+ :
165+ < p className = { 'text-xs text-neutral-400 text-center p-3' } >
166+ Server is offline.
167+ </ p >
168+ }
161169 </ TitledGreyBox >
162170 < TitledGreyBox title = { 'CPU usage' } icon = { faMicrochip } className = { 'flex-1 ml-2' } >
163- < canvas id = { 'cpu_chart' } ref = { cpuRef } aria-label = { 'Server CPU Usage Graph' } role = { 'img' } />
171+ { status !== 'offline' ?
172+ < canvas id = { 'cpu_chart' } ref = { cpuRef } aria-label = { 'Server CPU Usage Graph' } role = { 'img' } />
173+ :
174+ < p className = { 'text-xs text-neutral-400 text-center p-3' } >
175+ Server is offline.
176+ </ p >
177+ }
164178 </ TitledGreyBox >
165179 </ div >
166180 ) ;
0 commit comments