From c39811e700f37304a369926469ebf1891b69300f Mon Sep 17 00:00:00 2001 From: kieran Date: Thu, 4 Jul 2024 12:23:23 +0100 Subject: [PATCH] fix: load social graph for follows only --- packages/app/src/index.tsx | 2 +- packages/system/src/nostr-system.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/app/src/index.tsx b/packages/app/src/index.tsx index 967641fb..9b97242f 100644 --- a/packages/app/src/index.tsx +++ b/packages/app/src/index.tsx @@ -60,7 +60,7 @@ async function initSite() { const login = LoginStore.snapshot(); preload(login.state.follows).then(async () => { - await System.PreloadSocialGraph(); + await System.PreloadSocialGraph(login.state.follows); for (const ev of UserCache.snapshot()) { try { diff --git a/packages/system/src/nostr-system.ts b/packages/system/src/nostr-system.ts index f38aaba1..195718fe 100644 --- a/packages/system/src/nostr-system.ts +++ b/packages/system/src/nostr-system.ts @@ -131,13 +131,14 @@ export class NostrSystem extends SystemBase implements SystemInterface { this.userFollowsCache.preload(follows), ]; await Promise.all(t); - await this.PreloadSocialGraph(); + await this.PreloadSocialGraph(follows); } - async PreloadSocialGraph() { + async PreloadSocialGraph(follows?: Array) { // Insert data to socialGraph from cache if (this.config.buildFollowGraph) { for (const list of this.userFollowsCache.snapshot()) { + if (follows && !follows.includes(list.pubkey)) continue; const user = ID(list.pubkey); for (const fx of list.follows) { if (fx[0] === "p" && fx[1]?.length === 64) {