diff options
| author | Adam Soltys <[email protected]> | 2024-10-13 23:40:32 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-10-13 23:40:32 -0700 |
| commit | afbef8dd8dac9e1e71415914f2ecab7ce85f1fa5 (patch) | |
| tree | f447424cdc5c190d8b3b9b778e0f9291b58656e7 /lib/nostr.ts | |
| parent | 89163fd9a9e79bfc4d2e6cfe72ad109419705276 (diff) | |
| download | coinos-server-afbef8dd8dac9e1e71415914f2ecab7ce85f1fa5.tar.gz coinos-server-afbef8dd8dac9e1e71415914f2ecab7ce85f1fa5.zip | |
cache count
Diffstat (limited to 'lib/nostr.ts')
| -rw-r--r-- | lib/nostr.ts | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/nostr.ts b/lib/nostr.ts index 2e1dcd71..a58cb2c9 100644 --- a/lib/nostr.ts +++ b/lib/nostr.ts @@ -173,8 +173,10 @@ export let getCount = async (pubkey) => { follows = ev.tags .map((t) => t[0] === "p" && t[1]) .filter((p) => p && p.length === 64).length; - await s(`${pubkey}:follows:n`, follows); } + + follows ||= 0; + await s(`${pubkey}:follows:n`, follows); } if (!followers) { @@ -186,12 +188,11 @@ export let getCount = async (pubkey) => { if (f && f.content) { counts = JSON.parse(f.content); followers = counts[pubkey]; - await s(`${pubkey}:followers:n`, followers); } - } - follows ||= 0; - followers ||= 0; + followers ||= 0; + await s(`${pubkey}:followers:n`, followers); + } return { follows, followers }; }; |
