Skip to content

Commit

Permalink
fix: bridges types
Browse files Browse the repository at this point in the history
  • Loading branch information
chybisov committed Nov 11, 2022
1 parent f7f9a6d commit ac21920
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion packages/widget/src/hooks/useTelemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`,
);
Expand Down
6 changes: 5 additions & 1 deletion packages/widget/src/hooks/useTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import { useMemo } from 'react';
import { isItemAllowed, useLiFi, useWidgetConfig } from '../providers';
import { useSettingsStore } from '../stores';

interface WidgetBridge extends Omit<Bridge, 'key'> {
key: string;
}

type FormattedTool<T, K extends keyof T> = Record<string, Pick<T, K>>;

export const useTools = () => {
Expand Down Expand Up @@ -33,7 +37,7 @@ export const useTools = () => {
bridges: data?.bridges.reduce((bridges, bridge) => {
bridges[bridge.key] = bridge;
return bridges;
}, {} as FormattedTool<Bridge, 'key' | 'name' | 'logoURI'>),
}, {} as FormattedTool<WidgetBridge, 'key' | 'name' | 'logoURI'>),
exchanges: data?.exchanges.reduce((exchanges, exchange) => {
exchanges[exchange.key] = exchange;
return exchanges;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { Bridge } from '@lifi/sdk';
import { KeyboardArrowDown as KeyboardArrowDownIcon } from '@mui/icons-material';
import {
Box,
Expand Down Expand Up @@ -47,7 +46,7 @@ export const EnabledBridgesSelect: React.FC = () => {
</Box>
)}
>
{tools.bridges.map((bridge: Bridge) => (
{tools.bridges.map((bridge) => (
<MenuItem
key={bridge.key}
value={bridge.key}
Expand Down

0 comments on commit ac21920

Please sign in to comment.