diff --git a/packages/widget/src/hooks/useInitializer.ts b/packages/widget/src/hooks/useInitializer.ts index ab29665cf..ba8200343 100644 --- a/packages/widget/src/hooks/useInitializer.ts +++ b/packages/widget/src/hooks/useInitializer.ts @@ -4,9 +4,14 @@ import { useEffect } from 'react'; import { name, version } from '../config/version'; import { useTools } from './useTools'; +let checkedPackageUpdates = false; + export const useInitializer = () => { useTools(); useEffect(() => { - checkPackageUpdates(name, version); + if (!checkedPackageUpdates) { + checkedPackageUpdates = true; + checkPackageUpdates(name, version); + } }, []); }; diff --git a/packages/widget/src/hooks/useTools.ts b/packages/widget/src/hooks/useTools.ts index 6bfbf7268..8d07a2a05 100644 --- a/packages/widget/src/hooks/useTools.ts +++ b/packages/widget/src/hooks/useTools.ts @@ -10,27 +10,23 @@ type FormattedTool = Record>; export const useTools = () => { const lifi = useLiFi(); const { bridges, exchanges } = useWidgetConfig(); - const { data } = useQuery( - ['tools'], - ({ signal }) => lifi.getTools(undefined, { signal }), - { - onSuccess(data) { - const { initializeTools } = useSettingsStore.getState(); - initializeTools( - 'Bridges', - data.bridges - .filter((bridge) => isItemAllowed(bridge.key, bridges)) - .map((bridge) => bridge.key), - ); - initializeTools( - 'Exchanges', - data.exchanges - .filter((exchange) => isItemAllowed(exchange.key, exchanges)) - .map((exchange) => exchange.key), - ); - }, + const { data } = useQuery(['tools'], () => lifi.getTools(), { + onSuccess(data) { + const { initializeTools } = useSettingsStore.getState(); + initializeTools( + 'Bridges', + data.bridges + .filter((bridge) => isItemAllowed(bridge.key, bridges)) + .map((bridge) => bridge.key), + ); + initializeTools( + 'Exchanges', + data.exchanges + .filter((exchange) => isItemAllowed(exchange.key, exchanges)) + .map((exchange) => exchange.key), + ); }, - ); + }); const formattedTools = useMemo( () => ({