web: bug fixes

This commit is contained in:
Thomas Mathews 2022-12-20 23:19:38 -08:00
parent d9d293901b
commit 4cb4e77e6e
3 changed files with 16 additions and 15 deletions

View file

@ -2,8 +2,8 @@ let DAMUS
const BOOTSTRAP_RELAYS = [ const BOOTSTRAP_RELAYS = [
"wss://relay.damus.io", "wss://relay.damus.io",
"wss://nostr-relay.wlvs.space", //"wss://nostr-relay.wlvs.space",
"wss://nostr-pub.wellorder.net" //"wss://nostr-pub.wellorder.net"
] ]
// TODO autogenerate these constants with a bash script // TODO autogenerate these constants with a bash script
@ -35,9 +35,7 @@ async function damus_web_init_ready() {
if (!model.pubkey) if (!model.pubkey)
return return
const {RelayPool} = nostrjs model.ids = {
const pool = RelayPool(BOOTSTRAP_RELAYS)
const ids = {
comments: "comments", comments: "comments",
profiles: "profiles", profiles: "profiles",
explore: "explore", explore: "explore",
@ -49,7 +47,13 @@ async function damus_web_init_ready() {
unknowns: "unknowns", unknowns: "unknowns",
dms: "dms", dms: "dms",
} }
model.ids = ids
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 model.pool = pool
let err; let err;
@ -71,12 +75,8 @@ async function damus_web_init_ready() {
on_timer_timestamps(); on_timer_timestamps();
on_timer_invalidations(); on_timer_invalidations();
on_timer_save(); on_timer_save();
pool.on("open", on_pool_open);
pool.on("event", on_pool_event); return pool;
pool.on("notice", on_pool_notice);
pool.on("eose", on_pool_eose);
pool.on("ok", on_pool_ok);
return pool
} }
function on_timer_timestamps() { function on_timer_timestamps() {
@ -97,6 +97,7 @@ function on_timer_invalidations() {
function on_timer_save() { function on_timer_save() {
setTimeout(() => { setTimeout(() => {
model_save_events(DAMUS); model_save_events(DAMUS);
contacts_save(DAMUS.contacts);
on_timer_invalidations(); on_timer_invalidations();
}, 10 * 1000); }, 10 * 1000);
} }
@ -133,7 +134,6 @@ async function on_pool_eose(relay, sub_id) {
break; break;
case ids.profiles: case ids.profiles:
model.pool.unsubscribe(ids.profiles, relay); model.pool.unsubscribe(ids.profiles, relay);
on_eose_profiles(ids, model, relay)
break; break;
case ids.unknown: case ids.unknown:
pool.unsubscribe(ids.unknowns, relay); pool.unsubscribe(ids.unknowns, relay);

View file

@ -14,6 +14,7 @@ function filters_new_default(model) {
f[ids.contacts] = filters_new_contacts(friends); f[ids.contacts] = filters_new_contacts(friends);
f[ids.dms] = filters_new_dms(pubkey); f[ids.dms] = filters_new_dms(pubkey);
f[ids.notifications] = filters_new_notifications(pubkey); f[ids.notifications] = filters_new_notifications(pubkey);
f[ids.explore] = [{kinds: STANDARD_KINDS, limit: 500}];
return f; return f;
} }

View file

@ -49,7 +49,7 @@ function view_timeline_apply_mode(model, mode, opts={}) {
let count = 0; let count = 0;
const evs = model_events_arr(model) const evs = model_events_arr(model)
const fragment = new DocumentFragment(); 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]; const ev = evs[i];
if (!view_mode_contains_event(model, ev, mode, opts)) if (!view_mode_contains_event(model, ev, mode, opts))
continue; continue;