From a5d4ecf045f691b9059fcca925d0f30675d12db0 Mon Sep 17 00:00:00 2001 From: Cafe137 <77121044+Cafe137@users.noreply.github.com> Date: Mon, 3 Jun 2024 16:25:28 -0700 Subject: [PATCH] fix: add bee version (#659) --- src/pages/info/index.tsx | 3 ++- src/providers/Bee.tsx | 14 ++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/pages/info/index.tsx b/src/pages/info/index.tsx index b71a92c..af32f02 100644 --- a/src/pages/info/index.tsx +++ b/src/pages/info/index.tsx @@ -12,7 +12,7 @@ import NodeInfoCard from './NodeInfoCard' import { WalletInfoCard } from './WalletInfoCard' export default function Status(): ReactElement { - const { status, topology, nodeInfo, chainId } = useContext(BeeContext) + const { beeVersion, status, topology, nodeInfo, chainId } = useContext(BeeContext) const { isDesktop, desktopUrl } = useContext(SettingsContext) const { beeDesktopVersion } = useBeeDesktop(isDesktop, desktopUrl) const { newBeeDesktopVersion } = useNewBeeDesktopVersion(isDesktop, desktopUrl, false) @@ -52,6 +52,7 @@ export default function Status(): ReactElement { } /> )} + {chainId !== null && } diff --git a/src/providers/Bee.tsx b/src/providers/Bee.tsx index 0013021..11336eb 100644 --- a/src/providers/Bee.tsx +++ b/src/providers/Bee.tsx @@ -41,6 +41,7 @@ interface Status { } interface ContextInterface { + beeVersion: string | null status: Status error: Error | null apiHealth: boolean @@ -65,6 +66,7 @@ interface ContextInterface { } const initialValues: ContextInterface = { + beeVersion: null, status: { all: CheckState.ERROR, apiConnection: { isEnabled: false, checkState: CheckState.ERROR }, @@ -164,6 +166,7 @@ interface Props { export function Provider({ children }: Props): ReactElement { const { beeApi } = useContext(SettingsContext) + const [beeVersion, setBeeVersion] = useState(null) const [apiHealth, setApiHealth] = useState(false) const [nodeAddresses, setNodeAddresses] = useState(null) const [nodeInfo, setNodeInfo] = useState(null) @@ -262,11 +265,13 @@ export function Provider({ children }: Props): ReactElement { } const promises = [ - // API health beeApi - .isConnected({ timeout: TIMEOUT }) - .then(setApiHealth) - .catch(() => setApiHealth(false)), + .getHealth({ timeout: TIMEOUT }) + .then(response => setBeeVersion(response.version)) + .catch(() => setBeeVersion(null)), + + // API health + beeApi.isConnected({ timeout: TIMEOUT }).catch(() => setApiHealth(false)), // Node Addresses beeApi @@ -376,6 +381,7 @@ export function Provider({ children }: Props): ReactElement { return (