diff --git a/packages/bsky/src/api/app/bsky/actor/getSuggestions.ts b/packages/bsky/src/api/app/bsky/actor/getSuggestions.ts index 34add3f7926..d209a6f4cef 100644 --- a/packages/bsky/src/api/app/bsky/actor/getSuggestions.ts +++ b/packages/bsky/src/api/app/bsky/actor/getSuggestions.ts @@ -124,7 +124,7 @@ const presentation = (input: { }) => { const { ctx, skeleton, hydration } = input const actors = mapDefined(skeleton.dids, (did) => - ctx.views.profile(did, hydration), + ctx.views.profileKnownFollowers(did, hydration), ) return { actors, diff --git a/packages/bsky/src/views/index.ts b/packages/bsky/src/views/index.ts index 711c3a9f83e..3846a89b585 100644 --- a/packages/bsky/src/views/index.ts +++ b/packages/bsky/src/views/index.ts @@ -203,6 +203,29 @@ export class Views { } } + profileKnownFollowers( + did: string, + state: HydrationState, + ): ProfileView | undefined { + const actor = state.actors?.get(did) + if (!actor) return + const baseView = this.profile(did, state) + if (!baseView) return + const knownFollowersSkeleton = state.knownFollowers?.get(did) + const knownFollowers = knownFollowersSkeleton + ? this.knownFollowers(knownFollowersSkeleton, state) + : undefined + return { + ...baseView, + viewer: baseView.viewer + ? { + ...baseView.viewer, + knownFollowers, + } + : undefined, + } + } + profileViewer( did: string, state: HydrationState, diff --git a/packages/pds/tests/proxied/__snapshots__/views.test.ts.snap b/packages/pds/tests/proxied/__snapshots__/views.test.ts.snap index b0f682cfc19..8b061c4607d 100644 --- a/packages/pds/tests/proxied/__snapshots__/views.test.ts.snap +++ b/packages/pds/tests/proxied/__snapshots__/views.test.ts.snap @@ -179,22 +179,90 @@ Object { "viewer": Object { "blockedBy": false, "followedBy": "record(0)", + "knownFollowers": Object { + "count": 1, + "followers": Array [ + Object { + "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(0)@jpeg", + "createdAt": "1970-01-01T00:00:00.000Z", + "did": "user(2)", + "displayName": "ali", + "handle": "alice.test", + "labels": Array [ + Object { + "cid": "cids(1)", + "cts": "1970-01-01T00:00:00.000Z", + "src": "user(2)", + "uri": "record(3)", + "val": "self-label-a", + }, + Object { + "cid": "cids(1)", + "cts": "1970-01-01T00:00:00.000Z", + "src": "user(2)", + "uri": "record(3)", + "val": "self-label-b", + }, + ], + "viewer": Object { + "blockedBy": false, + "followedBy": "record(2)", + "following": "record(1)", + "muted": false, + }, + }, + ], + }, "muted": false, }, }, Object { - "did": "user(2)", + "did": "user(4)", "handle": "dan.test", "labels": Array [ Object { "cts": "1970-01-01T00:00:00.000Z", "src": "did:example:labeler", - "uri": "user(2)", + "uri": "user(4)", "val": "repo-action-label", }, ], "viewer": Object { "blockedBy": false, + "knownFollowers": Object { + "count": 1, + "followers": Array [ + Object { + "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(0)@jpeg", + "createdAt": "1970-01-01T00:00:00.000Z", + "did": "user(2)", + "displayName": "ali", + "handle": "alice.test", + "labels": Array [ + Object { + "cid": "cids(1)", + "cts": "1970-01-01T00:00:00.000Z", + "src": "user(2)", + "uri": "record(3)", + "val": "self-label-a", + }, + Object { + "cid": "cids(1)", + "cts": "1970-01-01T00:00:00.000Z", + "src": "user(2)", + "uri": "record(3)", + "val": "self-label-b", + }, + ], + "viewer": Object { + "blockedBy": false, + "followedBy": "record(2)", + "following": "record(1)", + "muted": false, + }, + }, + ], + }, "muted": false, }, },