From a0374566a5c69d87e5a156f5fabecf5b9b45d6f9 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 18 Aug 2026 12:06:04 -0700 Subject: A message sends the instant you let go of it: the rumor hashes synchronously onto the screen as a dimmed bubble, crypto and relays catch up in the background, and one small tick marks the moment a relay takes it Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_012u4oe1KPx9faCsDBLfZYqi --- src/dm.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/dm.js') diff --git a/src/dm.js b/src/dm.js index 70cf46b..85498f2 100644 --- a/src/dm.js +++ b/src/dm.js @@ -47,18 +47,26 @@ export async function wrapDM(skOrSigner, receiverPk, rumor, extraTags = []) { ); } -// A DM to a peer: the kind 14 rumor (unsigned, true timestamp) plus wraps for -// the recipient and for the sender's own inbox (the sent-copy). -export async function makeDM(skOrSigner, peerPk, text) { - const signer = asSigner(skOrSigner); +// The kind 14 rumor alone, id included — synchronous, so a sender can put +// the message on screen before any signing or encryption has run. Wrapping +// the same rumor later yields the same id, so the sent-copy echo dedupes. +export function makeDMRumor(senderPk, peerPk, text) { const rumor = { kind: 14, - pubkey: signer.pubkey, + pubkey: senderPk, content: text, tags: [['p', peerPk]], created_at: now(), }; rumor.id = getEventHash(rumor); + return rumor; +} + +// A DM to a peer: the kind 14 rumor (unsigned, true timestamp) plus wraps for +// the recipient and for the sender's own inbox (the sent-copy). +export async function makeDM(skOrSigner, peerPk, text) { + const signer = asSigner(skOrSigner); + const rumor = makeDMRumor(signer.pubkey, peerPk, text); return { rumor, toPeer: await wrapDM(signer, peerPk, rumor), -- cgit v1.2.3