Add network info in toolbar

This commit is contained in:
Franck Royer 2021-07-15 14:37:30 +10:00
parent 53412e2fb4
commit 5c790a41c9
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
2 changed files with 14 additions and 2 deletions

View File

@ -160,6 +160,7 @@ export default function App() {
nick={nick} nick={nick}
newMessages={newMessages} newMessages={newMessages}
archivedMessages={archivedMessages} archivedMessages={archivedMessages}
fleetEnv={fleetEnv}
commandHandler={(input: string) => { commandHandler={(input: string) => {
const { command, response } = handleCommand( const { command, response } = handleCommand(
input, input,

View File

@ -1,4 +1,4 @@
import { ChatMessage, WakuMessage } from 'js-waku'; import { ChatMessage, Environment, WakuMessage } from 'js-waku';
import { ChatContentTopic } from './App'; import { ChatContentTopic } from './App';
import ChatList from './ChatList'; import ChatList from './ChatList';
import MessageInput from './MessageInput'; import MessageInput from './MessageInput';
@ -11,17 +11,28 @@ interface Props {
archivedMessages: Message[]; archivedMessages: Message[];
commandHandler: (cmd: string) => void; commandHandler: (cmd: string) => void;
nick: string; nick: string;
fleetEnv: Environment;
} }
export default function Room(props: Props) { export default function Room(props: Props) {
const { waku } = useWaku(); const { waku } = useWaku();
let relayPeers = 0;
let storePeers = 0;
if (waku) {
relayPeers = waku.relay.getPeers().size;
storePeers = waku.store.peers.length;
}
return ( return (
<div <div
className="chat-container" className="chat-container"
style={{ height: '98vh', display: 'flex', flexDirection: 'column' }} style={{ height: '98vh', display: 'flex', flexDirection: 'column' }}
> >
<TitleBar title="Waku v2 chat app" /> <TitleBar
leftIcons={`Peers: ${relayPeers} relay, ${storePeers} store. Fleet: ${props.fleetEnv}`}
title="Waku v2 chat app"
/>
<ChatList <ChatList
newMessages={props.newMessages} newMessages={props.newMessages}
archivedMessages={props.archivedMessages} archivedMessages={props.archivedMessages}