mirror of https://github.com/waku-org/js-waku.git
Small cleanup
This commit is contained in:
parent
d6d52b72dd
commit
f6aa758712
|
@ -32,13 +32,24 @@ function App() {
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (!waku) return;
|
if (!waku) return;
|
||||||
if (wakuStatus !== 'Connected to Store') return;
|
|
||||||
|
// We do not handle disconnection/re-connection in this example
|
||||||
|
if (wakuStatus === 'Connected') return;
|
||||||
|
|
||||||
|
waku.waitForConnectedPeer().then(() => {
|
||||||
|
// We are now connected to a store node
|
||||||
|
setWakuStatus('Connected');
|
||||||
|
});
|
||||||
|
}, [waku, wakuStatus]);
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (!waku) return;
|
||||||
|
if (wakuStatus !== 'Connected') return;
|
||||||
|
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
waku.store
|
waku.store
|
||||||
.queryHistory([ContentTopic])
|
.queryHistory([ContentTopic])
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
// We may not be connected to a store node just yet
|
|
||||||
console.log('Failed to retrieve messages', e);
|
console.log('Failed to retrieve messages', e);
|
||||||
})
|
})
|
||||||
.then((retrievedMessages) => {
|
.then((retrievedMessages) => {
|
||||||
|
@ -51,18 +62,6 @@ function App() {
|
||||||
return () => clearInterval(interval);
|
return () => clearInterval(interval);
|
||||||
}, [waku, wakuStatus]);
|
}, [waku, wakuStatus]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
|
||||||
if (!waku) return;
|
|
||||||
|
|
||||||
// We do not handle disconnection/re-connection in this example
|
|
||||||
if (wakuStatus === 'Connected to Store') return;
|
|
||||||
|
|
||||||
waku.waitForConnectedPeer().then(() => {
|
|
||||||
// We are now connected to a store node
|
|
||||||
setWakuStatus('Connected to Store');
|
|
||||||
});
|
|
||||||
}, [waku, wakuStatus]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="App">
|
<div className="App">
|
||||||
<header className="App-header">
|
<header className="App-header">
|
||||||
|
|
Loading…
Reference in New Issue