mirror of
https://github.com/waku-org/js-waku.git
synced 2025-02-03 16:14:36 +00:00
Fix bad comparison logic
This commit is contained in:
parent
44db58d2fd
commit
66d450ae36
@ -58,20 +58,24 @@ export async function handleDirectMessage(
|
||||
console.log('Direct Message received:', wakuMsg);
|
||||
if (!wakuMsg.payload) return;
|
||||
const directMessage: DirectMessage = decode(wakuMsg.payload);
|
||||
// Do not return our own messages
|
||||
if (directMessage.toAddress === address) return;
|
||||
// Only decrypt messages for us
|
||||
if (!equalByteArrays(directMessage.toAddress, address)) return;
|
||||
|
||||
const text = await decryptMessage(privateKey, directMessage);
|
||||
try {
|
||||
const text = await decryptMessage(privateKey, directMessage);
|
||||
|
||||
const timestamp = wakuMsg.timestamp ? wakuMsg.timestamp : new Date();
|
||||
const timestamp = wakuMsg.timestamp ? wakuMsg.timestamp : new Date();
|
||||
|
||||
console.log('Message decrypted:', text);
|
||||
setter((prevMsgs: Message[]) => {
|
||||
const copy = prevMsgs.slice();
|
||||
copy.push({
|
||||
text: text,
|
||||
timestamp: timestamp,
|
||||
console.log('Message decrypted:', text);
|
||||
setter((prevMsgs: Message[]) => {
|
||||
const copy = prevMsgs.slice();
|
||||
copy.push({
|
||||
text: text,
|
||||
timestamp: timestamp,
|
||||
});
|
||||
return copy;
|
||||
});
|
||||
return copy;
|
||||
});
|
||||
} catch (e) {
|
||||
console.log(' Failed to decrypt message', e);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user