From 6038007d40b874507ff37266db263a40b70a4b2b Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 12 Aug 2021 15:15:56 +1000 Subject: [PATCH] No need for a wallet to send messages --- examples/eth-dm/src/App.tsx | 28 +++++++--------------------- examples/eth-dm/src/waku.ts | 2 +- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/examples/eth-dm/src/App.tsx b/examples/eth-dm/src/App.tsx index 3be1f410a3..db5df849ff 100644 --- a/examples/eth-dm/src/App.tsx +++ b/examples/eth-dm/src/App.tsx @@ -76,13 +76,6 @@ function App() { ); const [messages, setMessages] = useState([]); const [address, setAddress] = useState(); - const [peerStats, setPeerStats] = useState<{ - relayPeers: number; - lightPushPeers: number; - }>({ - relayPeers: 0, - lightPushPeers: 0, - }); const classes = useStyles(); @@ -101,7 +94,6 @@ function App() { useEffect(() => { if (!waku) return; - if (!address) return; const observerPublicKeyMessage = handlePublicKeyMessage.bind( {}, @@ -155,17 +147,12 @@ function App() { }; }, [waku, address, EncryptionKeyPair]); - useEffect(() => { - if (!waku) return; - - const interval = setInterval(() => { - setPeerStats({ - relayPeers: waku.relay.getPeers().size, - lightPushPeers: waku.lightPush.peers.length, - }); - }, 1000); - return () => clearInterval(interval); - }, [waku]); + let relayPeers = 0; + let lightPushPeers = 0; + if (waku) { + relayPeers = waku.relay.getPeers().size; + lightPushPeers = waku.lightPush.peers.length; + } let addressDisplay = ''; if (address) { @@ -189,8 +176,7 @@ function App() { /> - Peers: {peerStats.relayPeers} relay, {peerStats.lightPushPeers}{' '} - light push + Peers: {relayPeers} relay, {lightPushPeers} light push Ethereum Direct Message diff --git a/examples/eth-dm/src/waku.ts b/examples/eth-dm/src/waku.ts index befe3a9a43..1eded8b646 100644 --- a/examples/eth-dm/src/waku.ts +++ b/examples/eth-dm/src/waku.ts @@ -33,7 +33,7 @@ export async function initWaku(): Promise { } export function handlePublicKeyMessage( - myAddress: string, + myAddress: string | undefined, setter: Dispatch>>, msg: WakuMessage ) {