Mass Block [bsky] Reposts [and more]
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: fetch followers/following for profile mode in fetchEngagementData

Winter 80c30ea9 825eecf3

+31 -16
+31 -16
index.js
··· 470 470 } 471 471 472 472 // ── data fetching ─────────────────────────────────────────────────── 473 - async function fetchEngagementData(atUri, categories, blockAuthorFollowers) { 474 - const results = { reposts: [], likes: [], replies: [], authorFollowers: [], quotePosters: [] }; 473 + async function fetchEngagementData(target, categories, mode) { 474 + const results = { reposts: [], likes: [], replies: [], followers: [], following: [], quotePosters: [] }; 475 + const fetchers = []; 475 476 476 - const fetchers = []; 477 - if (categories.has("reposts")) { 478 - fetchers.push(fetchReposters(atUri).then((d) => { results.reposts = d; })); 477 + if (mode === "profile") { 478 + // target is a DID 479 + if (categories.has("followers")) { 480 + fetchers.push(fetchFollowers(target).then((d) => { results.followers = [...d]; })); 481 + } 482 + if (categories.has("following")) { 483 + fetchers.push( 484 + resolvePds(target).then((pdsUrl) => 485 + fetchFollowing(target, pdsUrl).then((d) => { results.following = [...d]; }) 486 + ) 487 + ); 488 + } 489 + } else { 490 + // post mode: target is an at:// URI 491 + if (categories.has("reposts")) { 492 + fetchers.push(fetchReposters(target).then((d) => { results.reposts = d; })); 493 + } 494 + if (categories.has("likes")) { 495 + fetchers.push(fetchLikers(target).then((d) => { results.likes = d; })); 496 + } 497 + if (categories.has("replies")) { 498 + fetchers.push(fetchRepliers(target).then((d) => { results.replies = d; })); 499 + } 500 + if (categories.has("followers")) { 501 + const authorDid = extractAuthorDid(target); 502 + fetchers.push(fetchFollowers(authorDid).then((d) => { results.followers = [...d]; })); 503 + } 504 + fetchers.push(fetchQuotePosters(target).then((d) => { results.quotePosters = d; })); 479 505 } 480 - if (categories.has("likes")) { 481 - fetchers.push(fetchLikers(atUri).then((d) => { results.likes = d; })); 482 - } 483 - if (categories.has("replies")) { 484 - fetchers.push(fetchRepliers(atUri).then((d) => { results.replies = d; })); 485 - } 486 - if (blockAuthorFollowers) { 487 - const authorDid = extractAuthorDid(atUri); 488 - fetchers.push(fetchFollowers(authorDid).then((d) => { results.authorFollowers = [...d]; })); 489 - } 490 - fetchers.push(fetchQuotePosters(atUri).then((d) => { results.quotePosters = d; })); 491 506 492 507 await Promise.all(fetchers); 493 508 return results;