1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15- import React , { useMemo , useEffect } from 'react'
16- import { useSelector , useDispatch } from 'react-redux'
15+ import React , { useMemo } from 'react'
16+ import { useSelector } from 'react-redux'
1717import { defineMessages } from 'react-intl'
18- import { useParams } from 'react-router-dom'
1918
2019import Panel from '@ttn-lw/components/panel'
2120import Icon , { IconGateway , IconInfoCircle , IconBolt , IconRouterOff } from '@ttn-lw/components/icon'
@@ -31,8 +30,6 @@ import PropTypes from '@ttn-lw/lib/prop-types'
3130import sharedMessages from '@ttn-lw/lib/shared-messages'
3231import { getBackendErrorName , isBackend } from '@ttn-lw/lib/errors/utils'
3332
34- import { startGatewayStatistics , stopGatewayStatistics } from '@console/store/actions/gateways'
35-
3633import {
3734 selectGatewayStatistics ,
3835 selectGatewayStatisticsError ,
@@ -107,20 +104,9 @@ EmptyState.propTypes = {
107104}
108105
109106const GatewayStatusPanel = ( ) => {
110- const { gtwId } = useParams ( )
111- const dispatch = useDispatch ( )
112107 const gatewayStats = useSelector ( selectGatewayStatistics )
113108 const error = useSelector ( selectGatewayStatisticsError )
114109 const fetching = useSelector ( selectGatewayStatisticsIsFetching )
115-
116- // Start statistics fetching when component mounts
117- useEffect ( ( ) => {
118- dispatch ( startGatewayStatistics ( gtwId ) )
119- return ( ) => {
120- dispatch ( stopGatewayStatistics ( ) )
121- }
122- } , [ dispatch , gtwId ] )
123-
124110 const isDisconnected = Boolean ( gatewayStats ?. disconnected_at )
125111 const isConnected = Boolean ( gatewayStats ?. connected_at ) && ! isDisconnected
126112 const isFetching = ! Boolean ( gatewayStats ) && fetching
@@ -131,7 +117,7 @@ const GatewayStatusPanel = () => {
131117 )
132118
133119 const hasError = Boolean ( error ) && Boolean ( error . message )
134- const isUnavailable = hasError && error . message === 'Unavailable'
120+ const isUnavailable = hasError && error . message === 'Unavailable' && ! fetching && ! gatewayStats
135121
136122 const maxRoundTripTime = useMemo (
137123 ( ) =>
0 commit comments