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 { useEffect, useState } from "react";
|
||||
import classNames from "classnames";
|
||||
import { getNetworkModuleStatus } from "@lumeweb/libkernel";
|
||||
import { callModule, getNetworkModuleStatus } from "@lumeweb/libkernel";
|
||||
|
||||
export default function Network({ module }) {
|
||||
let [ready, setReady] = useState(false);
|
||||
let [sync, setSync] = useState(null);
|
||||
let [peers, setPeers] = useState(0);
|
||||
let [name, setName] = useState();
|
||||
|
||||
useEffect(() => {
|
||||
const destroy = getNetworkModuleStatus((data) => {
|
||||
|
@ -15,6 +16,10 @@ export default function Network({ module }) {
|
|||
setPeers(data.peers);
|
||||
}, module);
|
||||
|
||||
callModule(module, "name").then((value) => {
|
||||
setName(value);
|
||||
});
|
||||
|
||||
return () => destroy?.();
|
||||
}, [module]);
|
||||
|
||||
|
@ -29,7 +34,7 @@ export default function Network({ module }) {
|
|||
"icon-wait": !ready,
|
||||
})}
|
||||
/>
|
||||
Network
|
||||
{name} Network
|
||||
</div>
|
||||
{ready ? (
|
||||
<div className="status">Synced</div>
|
||||
|
|
Reference in New Issue