From f00c3d267a5647a059814196434c97b4939770ca Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Fri, 8 Jul 2022 09:53:30 -0400 Subject: [PATCH] fix: handle empty payloads --- android/libs/.gitkeep | 0 download-gowaku.sh | 3 ++- example/src/App.tsx | 9 +++++++-- package.json | 3 ++- src/index.tsx | 2 +- 5 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 android/libs/.gitkeep diff --git a/android/libs/.gitkeep b/android/libs/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/download-gowaku.sh b/download-gowaku.sh index 1ea43dc..00d3a65 100755 --- a/download-gowaku.sh +++ b/download-gowaku.sh @@ -26,6 +26,7 @@ if ! test -d "./ios/Gowaku.xcframework"; then DOWNLOAD_IOS=true fi +mkdir -p tmp cd tmp rm -f ${SHA_FILE} @@ -69,4 +70,4 @@ if [ "$DOWNLOAD_IOS" = true ]; then mv -f ../ios/Gowaku.xcframework/ios-arm64_x86_64-simulator/Gowaku.framework/Versions/A/* ../ios/Gowaku.xcframework/ios-arm64_x86_64-simulator/Gowaku.framework/ rm -rf ../ios/Gowaku.xcframework/ios-arm64_x86_64-simulator/Gowaku.framework/Versions/A rm -rf ../ios/Gowaku.xcframework/ios-arm64/Gowaku.framework/Versions/A -fi \ No newline at end of file +fi diff --git a/example/src/App.tsx b/example/src/App.tsx index a6e1683..84996d4 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -6,6 +6,7 @@ import { defaultPubsubTopic, newNode, start, stop, peerID, relayEnoughPeers, lis export default function App() { const [result, setResult] = React.useState(); + const delay = ms => new Promise(res => setTimeout(res, ms)); React.useEffect(() => { (async () => { @@ -41,9 +42,13 @@ export default function App() { console.log("The messageID", messageID) - await relayUnsubscribe(); + // await delay(5000) // Waiting 5s before unsubscribing + + // console.log("Unsubscribing and stopping node...") + + // await relayUnsubscribe(); - await stop(); // TODO: This must be called only once + // await stop(); // TODO: This must be called only once })(); defaultPubsubTopic().then(setResult); diff --git a/package.json b/package.json index bcf7d4b..7a93e21 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@waku/react-native", - "version": "0.0.1-test1", + "version": "0.0.2", "description": "Waku React Native", "author": "Status Research & Development GMBH", "authors": [ @@ -56,6 +56,7 @@ }, "homepage": "https://github.com/status-im/waku-react-native#readme", "publishConfig": { + "access": "public", "registry": "https://registry.npmjs.org/" }, "devDependencies": { diff --git a/src/index.tsx b/src/index.tsx index a55eb53..b846653 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -45,7 +45,7 @@ export function onMessage(cb: (arg0:any) => void) { signal.event.wakuMessage.timestamp = msg.timestamp; signal.event.wakuMessage.version = msg.version || 0; signal.event.wakuMessage.contentTopic = msg.contentTopic; - signal.event.wakuMessage.payload = new Uint8Array(decode(msg.payload).split("").map((c:any) => c.charCodeAt(0))); + signal.event.wakuMessage.payload = new Uint8Array(decode(msg.payload ?? []).split("").map((c:any) => c.charCodeAt(0))); cb(signal.event); }) }