damus.io

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

commit 69575749e1e8e925b0ef33e7791c30e1ded1a489
parent d8ce0c221baa029c1f5bccf0396c41f622f90033
Author: William Casarin <jb55@jb55.com>
Date:   Fri, 11 Nov 2022 13:12:44 -0800

web: ignore all duplicate events

Diffstat:
Mweb/damus.js | 17+++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/web/damus.js b/web/damus.js @@ -289,6 +289,10 @@ function should_add_to_home(ev) let rerender_home_timer function handle_home_event(ids, model, relay, sub_id, ev) { + // ignore duplicates + if (model.all_events[ev.id]) + return + model.all_events[ev.id] = ev process_event(model, ev) @@ -325,8 +329,17 @@ function handle_home_event(ids, model, relay, sub_id, ev) { } } -function handle_profile_event(model, ev) { - console.log("PROFILE", ev) +function process_profile_event(model, ev) { + const prev_ev = model.profile_events[ev.pubkey] + if (prev_ev && prev_ev.created_at > ev.created_at) + return + + model.profile_events[ev.pubkey] = ev + try { + model.profiles[ev.pubkey] = JSON.parse(ev.content) + } catch(e) { + log_debug("failed to parse profile contents", ev) + } } function send_initial_filters(account_id, pubkey, relay) {