fix: load social graph for follows only
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
kieran 2024-07-04 12:23:23 +01:00
parent 69f6694f5c
commit c39811e700
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
2 changed files with 4 additions and 3 deletions

View File

@ -60,7 +60,7 @@ async function initSite() {
const login = LoginStore.snapshot(); const login = LoginStore.snapshot();
preload(login.state.follows).then(async () => { preload(login.state.follows).then(async () => {
await System.PreloadSocialGraph(); await System.PreloadSocialGraph(login.state.follows);
for (const ev of UserCache.snapshot()) { for (const ev of UserCache.snapshot()) {
try { try {

View File

@ -131,13 +131,14 @@ export class NostrSystem extends SystemBase implements SystemInterface {
this.userFollowsCache.preload(follows), this.userFollowsCache.preload(follows),
]; ];
await Promise.all(t); await Promise.all(t);
await this.PreloadSocialGraph(); await this.PreloadSocialGraph(follows);
} }
async PreloadSocialGraph() { async PreloadSocialGraph(follows?: Array<string>) {
// Insert data to socialGraph from cache // Insert data to socialGraph from cache
if (this.config.buildFollowGraph) { if (this.config.buildFollowGraph) {
for (const list of this.userFollowsCache.snapshot()) { for (const list of this.userFollowsCache.snapshot()) {
if (follows && !follows.includes(list.pubkey)) continue;
const user = ID(list.pubkey); const user = ID(list.pubkey);
for (const fx of list.follows) { for (const fx of list.follows) {
if (fx[0] === "p" && fx[1]?.length === 64) { if (fx[0] === "p" && fx[1]?.length === 64) {