From 96d8f148c2777965128641df7e753f23acb5a65f Mon Sep 17 00:00:00 2001 From: Jonathan Staab Date: Tue, 14 Mar 2023 15:46:55 -0500 Subject: [PATCH] Trim zapper info to avoid wasting space --- ROADMAP.md | 5 ++--- src/App.svelte | 9 ++++++--- src/agent/sync.ts | 6 +++++- src/agent/tables.ts | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index 32c26160..39f36445 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -2,9 +2,7 @@ - [ ] Fix memory usage - [x] Add table of user events, derive profile from this using `watch`. - - [ ] Remove petnames from users, retrieve lazily. Then, increase people table size - - [ ] Make zapper info more compact - - [ ] Move settings storage to an encrypted event https://github.com/nostr-protocol/nips/blob/master/78.md + - [x] Make zapper info more compact - [ ] Migrate - [ ] Test - [ ] Test that relays/follows made as anon don't stomp user settings on login @@ -100,6 +98,7 @@ - [ ] Ability to leave/mute DM conversation - [ ] Add notifications for chat messages - [ ] Add encrypted settings storage using nostr events + - [ ] github.com/nostr-protocol/nips/blob/master/78.md - [ ] Save DM/chat read status in encrypted note - [ ] Relay recommendations based on follows/followers - [ ] Pinned posts ala snort diff --git a/src/App.svelte b/src/App.svelte index a8586479..313cbfb8 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -14,7 +14,7 @@ import {timedelta, shuffle, now, sleep} from "src/util/misc" import {displayPerson, isLike} from "src/util/nostr" import cmd from "src/agent/cmd" - import {ready, onReady, relays} from "src/agent/tables" + import {onReady, relays} from "src/agent/tables" import keys from "src/agent/keys" import network from "src/agent/network" import pool from "src/agent/pool" @@ -69,6 +69,7 @@ export let url = "" + let ready = false let scrollY const closeModal = async () => { @@ -115,7 +116,9 @@ }) onReady(() => { - initializeRelayList() + initializeRelayList().then(() => { + ready = true + }) if (user.getProfile()) { loadAppData(user.getPubkey()) @@ -169,7 +172,7 @@
- {#if $ready} + {#if ready}
diff --git a/src/agent/sync.ts b/src/agent/sync.ts index 0e047452..2d5a5578 100644 --- a/src/agent/sync.ts +++ b/src/agent/sync.ts @@ -102,7 +102,11 @@ const verifyZapper = async (pubkey, address) => { const lnurl = lnurlEncode("lnurl", url) if (zapper?.allowsNostr && zapper?.nostrPubkey) { - updatePerson(pubkey, {zapper, lnurl}) + updatePerson(pubkey, { + lnurl, + // Trim zapper so we don't have so much metadata filling up memory + zapper: pick(["callback", "maxSendable", "minSendable", "nostrPubkey"], zapper), + }) } } diff --git a/src/agent/tables.ts b/src/agent/tables.ts index df5ae153..18275683 100644 --- a/src/agent/tables.ts +++ b/src/agent/tables.ts @@ -12,7 +12,7 @@ export const routes = new Table("routes", "id") export const getPersonWithFallback = pubkey => people.get(pubkey) || {pubkey} -export const ready = derived(pluck("ready", Object.values(registry)), all(identity)) +const ready = derived(pluck("ready", Object.values(registry)), all(identity)) export const onReady = cb => { const unsub = ready.subscribe($ready => {