From d9dbdf440142b3350000f5bd06584847e3ded6a7 Mon Sep 17 00:00:00 2001 From: MrMasrozYTLIVE <61359286+MrMasrozYTLIVE@users.noreply.github.com> Date: Mon, 10 Jun 2024 17:22:06 +0300 Subject: [PATCH] Oh i actually broke it because push returns length and not array itself :skull: --- app.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index 9ab3779..a7e629a 100644 --- a/app.js +++ b/app.js @@ -296,13 +296,17 @@ function sendMessage(e) { onMessageAdded(config.userName, message, config.userAvatar); + let peersPublicKeys = []; + peersPublicKeys.push([...swarm.connections].map(peer => peer.remotePublicKey.toString('hex'))); + peersPublicKeys.push(swarm.keyPair.publicKey.toString('hex')); + const messageObj = JSON.stringify({ type: 'message', name: config.userName, message, avatar: config.userAvatar, topic: b4a.toString(currentRoom.topic, 'hex'), - peers: [...swarm.connections].map(peer => peer.remotePublicKey.toString('hex')).push(swarm.keyPair.publicKey.toString('hex')), + peers: peersPublicKeys, timestamp: Date.now(), readableTimestamp: new Date().toLocaleString(), // Added human-readable timestamp });