damus.io

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

commit 42ff1042e3cd929c2ffb145dccee5416e3af2dd0
parent a393408e2d11782a892da76ad7caff958c05e879
Author: Thomas Mathews <thomas.c.mathews@gmail.com>
Date:   Wed, 14 Dec 2022 19:21:23 -0800

web: only redraw profile pic once or on force

Diffstat:
Mweb/js/damus.js | 13+++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/web/js/damus.js b/web/js/damus.js @@ -971,7 +971,7 @@ function handle_profiles_loaded(ids, model, view, relay) { model.pool.unsubscribe(ids.profiles, relay) //redraw_events(model, view) - //redraw_my_pfp(model) + redraw_my_pfp(model) const prefix = difficulty_to_prefix(model.pow) const fofs = Array.from(model.contacts.friend_of_friends) @@ -989,9 +989,14 @@ function handle_profiles_loaded(ids, model, view, relay) { model.pool.subscribe(ids.explore, explore_filters, relay) } -function redraw_my_pfp(model) { - const html = render_pfp(model.pubkey, model.profiles[model.pubkey]); - document.querySelector(".my-userpic").innerHTML = html; +function redraw_my_pfp(model, force = false) { + const p = model.profiles[model.pubkey] + if (!p) return; + const html = render_pfp(model.pubkey, p); + const el = document.querySelector(".my-userpic") + if (!force && el.dataset.loaded) return; + el.dataset.loaded = true; + el.innerHTML = html; } function debounce(f, interval) {