Skip to content

Commit

Permalink
fix: add bee version (#659)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cafe137 authored Jun 3, 2024
1 parent 1e67de0 commit a5d4ecf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/pages/info/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -52,6 +52,7 @@ export default function Status(): ReactElement {
}
/>
)}
<ExpandableListItem label="Bee version" value={beeVersion} />
<ExpandableListItem label="Mode" value={nodeInfo?.beeMode} />
{chainId !== null && <ExpandableListItem label="Blockchain network" value={chainIdToName(chainId)} />}
</div>
Expand Down
14 changes: 10 additions & 4 deletions src/providers/Bee.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ interface Status {
}

interface ContextInterface {
beeVersion: string | null
status: Status
error: Error | null
apiHealth: boolean
Expand All @@ -65,6 +66,7 @@ interface ContextInterface {
}

const initialValues: ContextInterface = {
beeVersion: null,
status: {
all: CheckState.ERROR,
apiConnection: { isEnabled: false, checkState: CheckState.ERROR },
Expand Down Expand Up @@ -164,6 +166,7 @@ interface Props {

export function Provider({ children }: Props): ReactElement {
const { beeApi } = useContext(SettingsContext)
const [beeVersion, setBeeVersion] = useState<string | null>(null)
const [apiHealth, setApiHealth] = useState<boolean>(false)
const [nodeAddresses, setNodeAddresses] = useState<NodeAddresses | null>(null)
const [nodeInfo, setNodeInfo] = useState<NodeInfo | null>(null)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -376,6 +381,7 @@ export function Provider({ children }: Props): ReactElement {
return (
<Context.Provider
value={{
beeVersion,
status,
error,
apiHealth,
Expand Down

0 comments on commit a5d4ecf

Please sign in to comment.