Skip to content

Commit

Permalink
Use detailed profile view for getSuggestions (#2596)
Browse files Browse the repository at this point in the history
* present detailed profile view for getSuggestions

* change lexicon to profileViewDetailed

* finish running the codegen

* update snapshot test for getSuggestions

* Revert "change lexicon to profileViewDetailed"

This reverts commit f0b167d.

Revert "update snapshot test for getSuggestions"

This reverts commit 2160951.

Revert "finish running the codegen"

This reverts commit 8bf3150.

* use basic profile + knownfollowers

* update snapshot test

* add createdAt to snapshot
  • Loading branch information
mozzius authored Jun 25, 2024
1 parent e956ac0 commit 4ddf457
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/bsky/src/api/app/bsky/actor/getSuggestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
23 changes: 23 additions & 0 deletions packages/bsky/src/views/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,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,
Expand Down
72 changes: 70 additions & 2 deletions packages/pds/tests/proxied/__snapshots__/views.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -187,22 +187,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,
},
},
Expand Down

0 comments on commit 4ddf457

Please sign in to comment.