diff --git a/packages/synapse-interface/components/Maintenance/functions/fetchJSONData.test.ts b/packages/synapse-interface/components/Maintenance/functions/fetchJSONData.test.ts index 975da54f7f..a31db2a2f2 100644 --- a/packages/synapse-interface/components/Maintenance/functions/fetchJSONData.test.ts +++ b/packages/synapse-interface/components/Maintenance/functions/fetchJSONData.test.ts @@ -1,4 +1,4 @@ -import { fetchJSONData } from './fetchJsonData' +import { fetchJSONData } from './fetchJSONData' const mockUrl = 'https://raw.githubusercontent.com/synapsecns/sanguine/test/maintenance/packages/synapse-interface/public/pauses/v1/paused-chains.json' @@ -27,7 +27,7 @@ describe('fetchJSONData', () => { }) test('retries the maximum number of times and fails', async () => { - const maxRetries = 5 + const maxRetries = 3 ;(fetch as jest.Mock).mockResolvedValue({ ok: false, status: 500, diff --git a/packages/synapse-interface/components/Maintenance/functions/fetchJsonData.ts b/packages/synapse-interface/components/Maintenance/functions/fetchJsonData.ts index 573b4dbfd2..fafd216edf 100644 --- a/packages/synapse-interface/components/Maintenance/functions/fetchJsonData.ts +++ b/packages/synapse-interface/components/Maintenance/functions/fetchJsonData.ts @@ -1,6 +1,6 @@ export const fetchJSONData = async (url: string): Promise => { // Configurable parameters - const maxRetries = 5 // maximum number of retries + const maxRetries = 3 // maximum number of retries const initialDelay = 1000 // initial delay in milliseconds // Helper function to delay for a given amount of time diff --git a/packages/synapse-interface/contexts/BackgroundListenerProvider.tsx b/packages/synapse-interface/contexts/BackgroundListenerProvider.tsx index 181b806ba2..5f3c5b1b70 100644 --- a/packages/synapse-interface/contexts/BackgroundListenerProvider.tsx +++ b/packages/synapse-interface/contexts/BackgroundListenerProvider.tsx @@ -8,10 +8,12 @@ import { useTransactionListener } from '@/utils/hooks/useTransactionListener' import { use_TransactionsListener } from '@/utils/hooks/use_TransactionsListener' import { useFetchPricesOnInterval } from '@/utils/hooks/useFetchPricesOnInterval' import { useFetchGasDataOnInterval } from '@/utils/hooks/useFetchGasDataOnInterval' +import { useMaintenanceListener } from '@/utils/hooks/useMaintenanceListener' const BackgroundListenerContext = createContext(null) export const BackgroundListenerProvider = ({ children }) => { + useMaintenanceListener() useApplicationListener() usePortfolioListener() useTransactionListener() diff --git a/packages/synapse-interface/contexts/MaintenanceProvider.tsx b/packages/synapse-interface/contexts/MaintenanceProvider.tsx deleted file mode 100644 index 75f222638e..0000000000 --- a/packages/synapse-interface/contexts/MaintenanceProvider.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import { createContext } from 'react' -import { getSynapsePauseData } from '@/components/Maintenance/functions/getSynapsePauseData' -import { useIntervalTimer } from '@/utils/hooks/useIntervalTimer' - -const MaintenanceContext = createContext(null) - -export const MaintenanceProvider = ({ children }) => { - const fetchMaintenanceData = getSynapsePauseData() - fetchMaintenanceData() - useIntervalTimer(60000) - - return ( - - {children} - - ) -} diff --git a/packages/synapse-interface/pages/_app.tsx b/packages/synapse-interface/pages/_app.tsx index 77f4959753..fd4f1d8c57 100644 --- a/packages/synapse-interface/pages/_app.tsx +++ b/packages/synapse-interface/pages/_app.tsx @@ -13,7 +13,6 @@ import setupLogRocketReact from 'logrocket-react' import { SegmentAnalyticsProvider } from '@/contexts/SegmentAnalyticsProvider' import { UserProvider } from '@/contexts/UserProvider' -import { MaintenanceProvider } from '@/contexts/MaintenanceProvider' import { BackgroundListenerProvider } from '@/contexts/BackgroundListenerProvider' import CustomToaster from '@/components/toast' import { SynapseProvider } from '@/utils/providers/SynapseProvider' @@ -52,12 +51,10 @@ function App({ Component, pageProps }: AppProps) { - - - - - - + + + + diff --git a/packages/synapse-interface/utils/hooks/useMaintenanceListener.ts b/packages/synapse-interface/utils/hooks/useMaintenanceListener.ts new file mode 100644 index 0000000000..d2e198292e --- /dev/null +++ b/packages/synapse-interface/utils/hooks/useMaintenanceListener.ts @@ -0,0 +1,15 @@ +import { useEffect } from 'react' + +import { useIntervalTimer } from './useIntervalTimer' +import { getSynapsePauseData } from '@/components/Maintenance/functions/getSynapsePauseData' + +export const useMaintenanceListener = () => { + const interval = useIntervalTimer(60000) + const fetchMaintenanceData = getSynapsePauseData() + + useEffect(() => { + fetchMaintenanceData() + }, [interval]) + + return null +}