fix: handle empty payloads

This commit is contained in:
Richard Ramos 2022-07-08 09:53:30 -04:00
parent 6f8c183ab6
commit f00c3d267a
No known key found for this signature in database
GPG Key ID: BD36D48BC9FFC88C
5 changed files with 12 additions and 5 deletions

0
android/libs/.gitkeep Normal file
View File

View File

@ -26,6 +26,7 @@ if ! test -d "./ios/Gowaku.xcframework"; then
DOWNLOAD_IOS=true
fi
mkdir -p tmp
cd tmp
rm -f ${SHA_FILE}

View File

@ -6,6 +6,7 @@ import { defaultPubsubTopic, newNode, start, stop, peerID, relayEnoughPeers, lis
export default function App() {
const [result, setResult] = React.useState<string | undefined>();
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
await stop(); // TODO: This must be called only once
// console.log("Unsubscribing and stopping node...")
// await relayUnsubscribe();
// await stop(); // TODO: This must be called only once
})();
defaultPubsubTopic().then(setResult);

View File

@ -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": {

View File

@ -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);
})
}