fix: stop polling on unauthenticated error

This commit is contained in:
André Sá 2021-10-29 13:18:00 +01:00
parent 8453a6ae85
commit 8d53e37ade

View file

@ -4,7 +4,7 @@ import BigNumber from 'bignumber.js'
import gql from 'graphql-tag' import gql from 'graphql-tag'
import { utils as coinUtils } from 'lamassu-coins' import { utils as coinUtils } from 'lamassu-coins'
import * as R from 'ramda' import * as R from 'ramda'
import React, { useState } from 'react' import React, { useEffect, useState } from 'react'
import { useHistory } from 'react-router-dom' import { useHistory } from 'react-router-dom'
import LogsDowloaderPopover from 'src/components/LogsDownloaderPopper' import LogsDowloaderPopover from 'src/components/LogsDownloaderPopper'
@ -123,13 +123,19 @@ const Transactions = () => {
GET_TRANSACTION_FILTERS GET_TRANSACTION_FILTERS
) )
const [variables, setVariables] = useState({ limit: NUM_LOG_RESULTS }) const [variables, setVariables] = useState({ limit: NUM_LOG_RESULTS })
const { data: txData, loading: loadingTransactions, refetch } = useQuery( const {
GET_TRANSACTIONS, data: txData,
{ loading: loadingTransactions,
variables, refetch,
pollInterval: 10000 startPolling,
} stopPolling
) } = useQuery(GET_TRANSACTIONS, { variables })
useEffect(() => {
startPolling(10000)
return stopPolling
})
const txList = txData ? txData.transactions : [] const txList = txData ? txData.transactions : []
const { data: configResponse, configLoading } = useQuery(GET_DATA) const { data: configResponse, configLoading } = useQuery(GET_DATA)