diff --git a/explorer/src/config.ts b/explorer/src/config.ts new file mode 100644 index 0000000000..1b1f83ce1f --- /dev/null +++ b/explorer/src/config.ts @@ -0,0 +1,4 @@ +export const config = { + IS_DEV_MODE: process.env.NODE_ENV === 'development', + LOG_TAURI_OPERATIONS: process.env.NODE_ENV === 'development', +}; diff --git a/explorer/src/context/hooks.ts b/explorer/src/context/hooks.ts index 76aa076050..9c5579c899 100644 --- a/explorer/src/context/hooks.ts +++ b/explorer/src/context/hooks.ts @@ -42,6 +42,6 @@ export const useApiState = ( setValue(newValue); return newValue; } - }, [setValue, fn]); + }, [setValue, fn, id, errorMessage]); return [value, wrappedFetchFn, clearValueFn]; }; diff --git a/explorer/src/pages/GatewayDetail/index.tsx b/explorer/src/pages/GatewayDetail/index.tsx index 45dc76c378..2f2c126a15 100644 --- a/explorer/src/pages/GatewayDetail/index.tsx +++ b/explorer/src/pages/GatewayDetail/index.tsx @@ -8,7 +8,7 @@ import { ComponentError } from '../../components/ComponentError'; import { ContentCard } from '../../components/ContentCard'; import { TwoColSmallTable } from '../../components/TwoColSmallTable'; import { UptimeChart } from '../../components/UptimeChart'; -// import { GatewayDetailSection } from '../../components/Gateways/DetailSection'; +import { Console } from '../../utils/console'; import { GatewayContextProvider, useGatewayContext } from '../../context/gateway'; import { useMainContext } from '../../context/main'; import { Title } from '../../components/Title'; @@ -64,9 +64,7 @@ const columns: ColumnsType[] = [ /** * Shows gateway details */ -const PageGatewayDetailsWithState: React.FC<{ selectedGateway: GatewayResponseItem | undefined }> = ({ - selectedGateway, -}) => { +const PageGatewayDetailsWithState = ({ selectedGateway }: { selectedGateway: GatewayResponseItem | undefined }) => { const [enrichGateway, setEnrichGateway] = React.useState(); const [status, setStatus] = React.useState(); const { uptimeReport, uptimeStory } = useGatewayContext(); @@ -105,7 +103,7 @@ const PageGatewayDetailsWithState: React.FC<{ selectedGateway: GatewayResponseIt loading={false} keys={['Mix port', 'Client WS API Port']} values={status.map((each) => each)} - icons={status.map((elem) => !!elem) || [false, false]} + icons={status.map((elem) => !!elem)} /> )} @@ -135,7 +133,7 @@ const PageGatewayDetailGuard: React.FC = () => { if (gateways?.data) { setSelectedGateway(gateways.data.find((gateway) => gateway.gateway.identity_key === id)); } - }, [gateways]); + }, [gateways, id]); if (gateways?.isLoading) { return ; @@ -143,7 +141,7 @@ const PageGatewayDetailGuard: React.FC = () => { if (gateways?.error) { // eslint-disable-next-line no-console - console.error(gateways?.error); + Console.error(gateways?.error); return ( Oh no! Could not load mixnode {id || ''} diff --git a/explorer/src/utils/console.ts b/explorer/src/utils/console.ts new file mode 100644 index 0000000000..517f0c6aca --- /dev/null +++ b/explorer/src/utils/console.ts @@ -0,0 +1,10 @@ +/* eslint-disable no-console */ +import { config } from '../config'; + +export const Console = { + log: (message?: any, ...optionalParams: any[]) => + config.IS_DEV_MODE ? console.log(message, ...optionalParams) : undefined, + warn: (message?: any, ...optionalParams: any[]) => + config.IS_DEV_MODE ? console.warn(message, ...optionalParams) : undefined, + error: (message?: any, ...optionalParams: any[]) => console.error(message, ...optionalParams), +};