damus.io

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

commit 994305ccff4484959154afdb9c2e15e4bc6e523e
parent 4fd24c041442f7a1c476c5508df9f96bf5cb9cc2
Author: William Casarin <jb55@jb55.com>
Date:   Sun, 20 Nov 2022 09:28:35 -0800

switch to new share spec

Diffstat:
Mweb/css/styles.css | 2+-
Mweb/js/damus.js | 3+--
Mweb/js/ui/render.js | 22++++++++++++----------
3 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/web/css/styles.css b/web/css/styles.css @@ -243,7 +243,7 @@ button.nav > img.icon { border-top: 1px solid var(--clrBorder); } -.timestamp, .replying-to, .boosted-by { +.timestamp, .replying-to, .shared-by { font-size: var(--fsSmall); color: var(--clrTextLight); } diff --git a/web/js/damus.js b/web/js/damus.js @@ -947,8 +947,7 @@ function delete_post_confirm(evid) { } function shouldnt_render_event(our_pk, view, ev, opts) { - return !opts.is_boost_event && - !opts.is_composing && + return !opts.is_composing && !view.expanded.has(ev.id) && view.rendered.has(ev.id) } diff --git a/web/js/ui/render.js b/web/js/ui/render.js @@ -96,17 +96,19 @@ function render_unknown_event(damus, ev) { return "Unknown event " + ev.kind } -function render_boost(damus, view, ev, opts) { +function render_share(damus, view, ev, opts) { //todo validate content - if (!ev.json_content) + const shared_ev = damus.all_events[ev.refs && ev.refs.root] + // share isn't resolved yet. that's ok, we can render this when we have + // the event + if (!shared_ev) return "" - //const profile = model.profiles[ev.pubkey] - opts.boosted = { + opts.shared = { pubkey: ev.pubkey, profile: damus.profiles[ev.pubkey] } - return render_event(damus, view, ev.json_content, opts) + return render_event(damus, view, shared_ev, opts) } function render_comment_body(damus, ev, opts) { @@ -117,7 +119,7 @@ function render_comment_body(damus, ev, opts) { return ` <div> ${render_replying_to(damus, ev)} - ${render_boosted_by(ev, opts)} + ${render_shared_by(ev, opts)} </div> <p> ${format_content(ev, show_media)} @@ -127,13 +129,13 @@ function render_comment_body(damus, ev, opts) { ` } -function render_boosted_by(ev, opts) { - const b = opts.boosted +function render_shared_by(ev, opts) { + const b = opts.shared if (!b) { return "" } return ` - <div class="boosted-by"> + <div class="shared-by"> Shared by ${render_name(b.pubkey, b.profile)} </div> ` @@ -157,7 +159,7 @@ function render_deleted_comment_body(ev, deleted) { function render_event(damus, view, ev, opts={}) { if (ev.kind === 6) - return render_boost(damus, view, ev, opts) + return render_share(damus, view, ev, opts) if (shouldnt_render_event(damus.pubkey, view, ev, opts)) return ""