From 646a0a2daf8eddaeed4aba983ca3502cce91079d Mon Sep 17 00:00:00 2001 From: Thomas Mathews Date: Tue, 27 Dec 2022 20:21:12 -0800 Subject: [PATCH] Added reply one/all because it was annoying me --- js/core.js | 32 +++++++++++++++++++++----------- js/ui/render.js | 5 ++++- js/ui/util.js | 14 ++++++++++++-- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/js/core.js b/js/core.js index 2574065..3d6a498 100644 --- a/js/core.js +++ b/js/core.js @@ -129,30 +129,40 @@ async function send_post() { post_input_changed(input_el) } +function new_reply_tags(ev) { + return [ + ["e", ev.id, "", "reply"], + ["p", ev.pubkey], + ]; +} -async function create_reply(pubkey, content, from) { - const tags = gather_reply_tags(pubkey, from) - const created_at = Math.floor(new Date().getTime() / 1000) - let kind = from.kind +async function create_reply(pubkey, content, ev, all=true) { + const tags = all ? gather_reply_tags(pubkey, ev) : new_reply_tags(ev); + const created_at = new_creation_time(); + let kind = ev.kind; // convert emoji replies into reactions if (is_valid_reaction_content(content)) - kind = 7 - - let reply = { pubkey, tags, content, created_at, kind } - + kind = 7; + let reply = { + pubkey, + tags, + content, + created_at, + kind + } reply.id = await nostrjs.calculate_id(reply) reply = await sign_event(reply) return reply } -async function send_reply(content, replying_to) { +async function send_reply(content, replying_to, all=true) { const ev = DAMUS.all_events[replying_to] if (!ev) - return + return; const pubkey = await get_pubkey() - let reply = await create_reply(pubkey, content, ev) + let reply = await create_reply(pubkey, content, ev, all) broadcast_event(reply) broadcast_related_events(reply) diff --git a/js/ui/render.js b/js/ui/render.js index 3ac13b6..4ddf115 100644 --- a/js/ui/render.js +++ b/js/ui/render.js @@ -226,9 +226,12 @@ function render_action_bar(model, ev, opts={}) { const reaction_id = reaction ? reaction.id : ""; return html`
- +