Oh i actually broke it because push returns length and not array itself 💀

This commit is contained in:
MrMasrozYTLIVE 2024-06-10 17:22:06 +03:00
parent 961599f366
commit d9dbdf4401

6
app.js
View File

@ -296,13 +296,17 @@ function sendMessage(e) {
onMessageAdded(config.userName, message, config.userAvatar); 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({ const messageObj = JSON.stringify({
type: 'message', type: 'message',
name: config.userName, name: config.userName,
message, message,
avatar: config.userAvatar, avatar: config.userAvatar,
topic: b4a.toString(currentRoom.topic, 'hex'), 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(), timestamp: Date.now(),
readableTimestamp: new Date().toLocaleString(), // Added human-readable timestamp readableTimestamp: new Date().toLocaleString(), // Added human-readable timestamp
}); });