damus.io

damus.io website
git clone git://jb55.com/damus.io
Log | Files | Refs | README

commit 8978a11579584684260b43ad95564bbcaa5834b4
parent f5ba022bbad6a49c7f9d074371eaa0a1d6dcd6a7
Author: William Casarin <jb55@jb55.com>
Date:   Fri, 28 Oct 2022 11:15:11 -0700

render reactions, only allow replies on text and chats

Diffstat:
Mwebv2/damus.js | 19+++++++++++++++----
Mwebv2/index.html | 2+-
2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/webv2/damus.js b/webv2/damus.js @@ -448,6 +448,10 @@ function render_reply_line_bot() { return `<div class="line-bot"></div>` } +function can_reply(ev) { + return ev.kind === 1 || ev.kind === 42 +} + function render_event(model, ev, opts={}) { if (!opts.is_composing && model.rendered[ev.id]) return "" @@ -458,7 +462,7 @@ function render_event(model, ev, opts={}) { } const delta = time_delta(new Date().getTime(), ev.created_at*1000) const pk = ev.pubkey - const bar = opts.nobar? "" : render_action_bar(ev) + const bar = !can_reply(ev) || opts.nobar? "" : render_action_bar(ev) let replying_to = "" let reply_line_top = "" @@ -490,7 +494,8 @@ function render_event(model, ev, opts={}) { ${reply_line_bot} </div> <p> - ${format_content(ev.content)} + + ${format_content(ev)} ${bar} </p> @@ -660,9 +665,15 @@ function convert_quote_blocks(content) }, "") } -function format_content(content) +function format_content(ev) { - return convert_quote_blocks(content) + if (ev.kind === 7) { + if (ev.content === "" || ev.content === "+") + return "❤️" + return sanitize(ev.content) + } + + return convert_quote_blocks(ev.content) } function sanitize(content) diff --git a/webv2/index.html b/webv2/index.html @@ -41,7 +41,7 @@ <script src="noble-secp256k1.js?v=1"></script> <script src="bech32.js?v=1"></script> <script src="nostr.js?v=5"></script> - <script src="damus.js?v=27"></script> + <script src="damus.js?v=28"></script> <script> // I have to delay loading to wait for nos2x const relay = setTimeout(damus_web_init, 100)