From ac219205d4823f286aa28988b096939ab8ff9bca Mon Sep 17 00:00:00 2001 From: Eugene Chybisov Date: Fri, 11 Nov 2022 17:36:09 +0000 Subject: [PATCH] fix: bridges types --- packages/widget/src/hooks/useTelemetry.ts | 5 ++++- packages/widget/src/hooks/useTools.ts | 6 +++++- .../widget/src/pages/SettingsPage/EnabledBridgesSelect.tsx | 3 +-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/widget/src/hooks/useTelemetry.ts b/packages/widget/src/hooks/useTelemetry.ts index 9daa151b3..a7652077c 100644 --- a/packages/widget/src/hooks/useTelemetry.ts +++ b/packages/widget/src/hooks/useTelemetry.ts @@ -3,10 +3,13 @@ import { useEffect } from 'react'; import { initSentry } from '../config/sentry'; import { name } from '../config/version'; +let warningLogged = false; + export const useTelemetry = (disabled?: boolean) => { useEffect(() => { if (disabled) { - if (process.env.NODE_ENV === 'development') { + if (process.env.NODE_ENV === 'development' && !warningLogged) { + warningLogged = true; console.warn( `[${name}] Enable crash reports and diagnostic data to be collected. This helps us to better understand how the widget is performing and where improvements need to be made.`, ); diff --git a/packages/widget/src/hooks/useTools.ts b/packages/widget/src/hooks/useTools.ts index 8d07a2a05..89663114e 100644 --- a/packages/widget/src/hooks/useTools.ts +++ b/packages/widget/src/hooks/useTools.ts @@ -5,6 +5,10 @@ import { useMemo } from 'react'; import { isItemAllowed, useLiFi, useWidgetConfig } from '../providers'; import { useSettingsStore } from '../stores'; +interface WidgetBridge extends Omit { + key: string; +} + type FormattedTool = Record>; export const useTools = () => { @@ -33,7 +37,7 @@ export const useTools = () => { bridges: data?.bridges.reduce((bridges, bridge) => { bridges[bridge.key] = bridge; return bridges; - }, {} as FormattedTool), + }, {} as FormattedTool), exchanges: data?.exchanges.reduce((exchanges, exchange) => { exchanges[exchange.key] = exchange; return exchanges; diff --git a/packages/widget/src/pages/SettingsPage/EnabledBridgesSelect.tsx b/packages/widget/src/pages/SettingsPage/EnabledBridgesSelect.tsx index 6b64d3437..884afcad8 100644 --- a/packages/widget/src/pages/SettingsPage/EnabledBridgesSelect.tsx +++ b/packages/widget/src/pages/SettingsPage/EnabledBridgesSelect.tsx @@ -1,4 +1,3 @@ -import type { Bridge } from '@lifi/sdk'; import { KeyboardArrowDown as KeyboardArrowDownIcon } from '@mui/icons-material'; import { Box, @@ -47,7 +46,7 @@ export const EnabledBridgesSelect: React.FC = () => { )} > - {tools.bridges.map((bridge: Bridge) => ( + {tools.bridges.map((bridge) => (