diff options
| -rw-r--r-- | lib/nostr.ts | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/nostr.ts b/lib/nostr.ts index aca518b6..0bb01521 100644 --- a/lib/nostr.ts +++ b/lib/nostr.ts @@ -158,7 +158,7 @@ export const getCount = async (pubkey) => { if (follows === null) { const result = await get({ authors: [pubkey], kinds: [3] }); follows = result ? result.tags.filter((t) => t[0] === "p").length : 0; - await db.set(`${pubkey}:follows:n`, follows, { EX }); + if (follows?.length) await db.set(`${pubkey}:follows:n`, JSON.stringify(follows), { EX }); } const k = `${pubkey}:followers:n`; @@ -169,7 +169,8 @@ export const getCount = async (pubkey) => { "#p": [pubkey], kinds: [3], }); - await db.set(k, followers, { EX }); + + if (followers?.length) await db.set(k, JSON.stringify(followers), { EX }); } return { follows, followers }; |
