Skip to content

Commit 6736c24

Browse files
committed
console: Fix gateway status
1 parent b7df0e8 commit 6736c24

1 file changed

Lines changed: 3 additions & 17 deletions

File tree

  • pkg/webui/console/containers/gateway-status-panel

pkg/webui/console/containers/gateway-status-panel/index.js

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
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'
1717
import { defineMessages } from 'react-intl'
18-
import { useParams } from 'react-router-dom'
1918

2019
import Panel from '@ttn-lw/components/panel'
2120
import Icon, { IconGateway, IconInfoCircle, IconBolt, IconRouterOff } from '@ttn-lw/components/icon'
@@ -31,8 +30,6 @@ import PropTypes from '@ttn-lw/lib/prop-types'
3130
import sharedMessages from '@ttn-lw/lib/shared-messages'
3231
import { getBackendErrorName, isBackend } from '@ttn-lw/lib/errors/utils'
3332

34-
import { startGatewayStatistics, stopGatewayStatistics } from '@console/store/actions/gateways'
35-
3633
import {
3734
selectGatewayStatistics,
3835
selectGatewayStatisticsError,
@@ -107,20 +104,9 @@ EmptyState.propTypes = {
107104
}
108105

109106
const 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

Comments
 (0)