From cbe44430336b13f5568db9a5e8e7abd270bb3665 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Tue, 26 Jul 2022 14:14:26 -0400 Subject: [PATCH] update example --- example/src/App.tsx | 19 +++++++++++++++---- go-waku.VERSION | 2 +- ios/ReactNative.swift | 2 +- package.json | 2 +- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/example/src/App.tsx b/example/src/App.tsx index 84996d4..15a5680 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { StyleSheet, View, Text } from 'react-native'; -import { defaultPubsubTopic, newNode, start, stop, peerID, relayEnoughPeers, listenAddresses, connect, peerCnt, peers, relayPublish, relayUnsubscribe, relaySubscribe, WakuMessage, onMessage } from '@waku/react-native'; +import { defaultPubsubTopic, newNode, start, isStarted, stop, peerID, relayEnoughPeers, listenAddresses, connect, peerCnt, peers, relayPublish, relayUnsubscribe, relaySubscribe, WakuMessage, onMessage, storeQuery, StoreQuery } from '@waku/react-native'; export default function App() { const [result, setResult] = React.useState(); @@ -10,9 +10,12 @@ export default function App() { React.useEffect(() => { (async () => { - await newNode(null); // TODO: This must be called only once - await start(); // // TODO: This must be called only once + const nodeStarted = await isStarted(); + if (!nodeStarted) { + await newNode(null); + await start(); + } console.log("The node ID:", await peerID()) await relaySubscribe() @@ -27,7 +30,7 @@ export default function App() { await connect("/dns4/node-01.ac-cn-hongkong-c.wakuv2.test.statusim.net/tcp/30303/p2p/16Uiu2HAkvWiyFsgRhuJEb9JfjYxEkoHLgnUQmr1N5mKWnYjxYRVm", 5000) - console.log("connected!") + console.log("connected!") console.log("PeerCNT", await peerCnt()) console.log("Peers", await peers()) @@ -42,6 +45,14 @@ export default function App() { console.log("The messageID", messageID) + /* + console.log("Retrieving messages from store node") + const query = new StoreQuery(); + //query.contentFilters.push("/toy-chat/2/luzhou/proto") + const queryResult = await storeQuery(query, "16Uiu2HAkvWiyFsgRhuJEb9JfjYxEkoHLgnUQmr1N5mKWnYjxYRVm") + console.log(queryResult) + */ + // await delay(5000) // Waiting 5s before unsubscribing // console.log("Unsubscribing and stopping node...") diff --git a/go-waku.VERSION b/go-waku.VERSION index 6c6aa7c..341cf11 100644 --- a/go-waku.VERSION +++ b/go-waku.VERSION @@ -1 +1 @@ -0.1.0 \ No newline at end of file +0.2.0 \ No newline at end of file diff --git a/ios/ReactNative.swift b/ios/ReactNative.swift index 2d2b814..23fb534 100644 --- a/ios/ReactNative.swift +++ b/ios/ReactNative.swift @@ -63,7 +63,7 @@ class ReactNative: RCTEventEmitter { } @objc(isStarted:withRejecter:) - func stop(_ resolve:RCTPromiseResolveBlock, withRejecter reject:RCTPromiseRejectBlock) -> Void { + func isStarted(_ resolve:RCTPromiseResolveBlock, withRejecter reject:RCTPromiseRejectBlock) -> Void { resolve(GowakuIsStarted()) } diff --git a/package.json b/package.json index 7a93e21..b872dd9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@waku/react-native", - "version": "0.0.2", + "version": "0.0.4", "description": "Waku React Native", "author": "Status Research & Development GMBH", "authors": [