From 4cb4e77e6e72c29875ab7b9a982c35c89cde6cdf Mon Sep 17 00:00:00 2001 From: Thomas Mathews Date: Tue, 20 Dec 2022 23:19:38 -0800 Subject: [PATCH] web: bug fixes --- web/js/damus.js | 28 ++++++++++++++-------------- web/js/filters.js | 1 + web/js/ui/state.js | 2 +- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/web/js/damus.js b/web/js/damus.js index f48e35d..8fa2f77 100644 --- a/web/js/damus.js +++ b/web/js/damus.js @@ -2,8 +2,8 @@ let DAMUS const BOOTSTRAP_RELAYS = [ "wss://relay.damus.io", - "wss://nostr-relay.wlvs.space", - "wss://nostr-pub.wellorder.net" + //"wss://nostr-relay.wlvs.space", + //"wss://nostr-pub.wellorder.net" ] // TODO autogenerate these constants with a bash script @@ -35,9 +35,7 @@ async function damus_web_init_ready() { if (!model.pubkey) return - const {RelayPool} = nostrjs - const pool = RelayPool(BOOTSTRAP_RELAYS) - const ids = { + model.ids = { comments: "comments", profiles: "profiles", explore: "explore", @@ -49,9 +47,15 @@ async function damus_web_init_ready() { unknowns: "unknowns", dms: "dms", } - model.ids = ids - model.pool = pool + const pool = nostrjs.RelayPool(BOOTSTRAP_RELAYS); + pool.on("open", on_pool_open); + pool.on("event", on_pool_event); + pool.on("notice", on_pool_notice); + pool.on("eose", on_pool_eose); + pool.on("ok", on_pool_ok); + model.pool = pool + let err; err = await contacts_load(model); if (err) { @@ -71,12 +75,8 @@ async function damus_web_init_ready() { on_timer_timestamps(); on_timer_invalidations(); on_timer_save(); - pool.on("open", on_pool_open); - pool.on("event", on_pool_event); - pool.on("notice", on_pool_notice); - pool.on("eose", on_pool_eose); - pool.on("ok", on_pool_ok); - return pool + + return pool; } function on_timer_timestamps() { @@ -97,6 +97,7 @@ function on_timer_invalidations() { function on_timer_save() { setTimeout(() => { model_save_events(DAMUS); + contacts_save(DAMUS.contacts); on_timer_invalidations(); }, 10 * 1000); } @@ -133,7 +134,6 @@ async function on_pool_eose(relay, sub_id) { break; case ids.profiles: model.pool.unsubscribe(ids.profiles, relay); - on_eose_profiles(ids, model, relay) break; case ids.unknown: pool.unsubscribe(ids.unknowns, relay); diff --git a/web/js/filters.js b/web/js/filters.js index c84deef..64fd5c7 100644 --- a/web/js/filters.js +++ b/web/js/filters.js @@ -14,6 +14,7 @@ function filters_new_default(model) { f[ids.contacts] = filters_new_contacts(friends); f[ids.dms] = filters_new_dms(pubkey); f[ids.notifications] = filters_new_notifications(pubkey); + f[ids.explore] = [{kinds: STANDARD_KINDS, limit: 500}]; return f; } diff --git a/web/js/ui/state.js b/web/js/ui/state.js index 3ebd286..7b78615 100644 --- a/web/js/ui/state.js +++ b/web/js/ui/state.js @@ -49,7 +49,7 @@ function view_timeline_apply_mode(model, mode, opts={}) { let count = 0; const evs = model_events_arr(model) const fragment = new DocumentFragment(); - for (let i = evs.length - 1; i >= 0 && count < 50000; i--) { + for (let i = evs.length - 1; i >= 0 && count < 1000; i--) { const ev = evs[i]; if (!view_mode_contains_event(model, ev, mode, opts)) continue;