feat: add support for fetching and rendering the network name
This commit is contained in:
parent
0706a61817
commit
b0974c7200
|
@ -1,12 +1,13 @@
|
||||||
import "./Network.scss";
|
import "./Network.scss";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { getNetworkModuleStatus } from "@lumeweb/libkernel";
|
import { callModule, getNetworkModuleStatus } from "@lumeweb/libkernel";
|
||||||
|
|
||||||
export default function Network({ module }) {
|
export default function Network({ module }) {
|
||||||
let [ready, setReady] = useState(false);
|
let [ready, setReady] = useState(false);
|
||||||
let [sync, setSync] = useState(null);
|
let [sync, setSync] = useState(null);
|
||||||
let [peers, setPeers] = useState(0);
|
let [peers, setPeers] = useState(0);
|
||||||
|
let [name, setName] = useState();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const destroy = getNetworkModuleStatus((data) => {
|
const destroy = getNetworkModuleStatus((data) => {
|
||||||
|
@ -15,6 +16,10 @@ export default function Network({ module }) {
|
||||||
setPeers(data.peers);
|
setPeers(data.peers);
|
||||||
}, module);
|
}, module);
|
||||||
|
|
||||||
|
callModule(module, "name").then((value) => {
|
||||||
|
setName(value);
|
||||||
|
});
|
||||||
|
|
||||||
return () => destroy?.();
|
return () => destroy?.();
|
||||||
}, [module]);
|
}, [module]);
|
||||||
|
|
||||||
|
@ -29,7 +34,7 @@ export default function Network({ module }) {
|
||||||
"icon-wait": !ready,
|
"icon-wait": !ready,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
Network
|
{name} Network
|
||||||
</div>
|
</div>
|
||||||
{ready ? (
|
{ready ? (
|
||||||
<div className="status">Synced</div>
|
<div className="status">Synced</div>
|
||||||
|
|
Reference in New Issue