Skip to content

Commit

Permalink
Add labels to actor search typeahead results (#1940)
Browse files Browse the repository at this point in the history
add labels to appview actor search typeahead
  • Loading branch information
devinivy authored Dec 7, 2023
1 parent cbc94ac commit 842e183
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function (server: Server, ctx: AppContext) {

const actors = await ctx.services
.actor(db)
.views.profilesBasic(results, requester, { omitLabels: true })
.views.profilesBasic(results, requester)

const SKIP = []
const filtered = results.flatMap((did) => {
Expand Down
9 changes: 3 additions & 6 deletions packages/bsky/src/services/actor/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ export class ActorViews {
async profilesBasic(
results: (ActorResult | string)[],
viewer: string | null,
opts?: { omitLabels?: boolean; includeSoftDeleted?: boolean },
opts?: { includeSoftDeleted?: boolean },
): Promise<ActorInfoMap> {
if (results.length === 0) return {}
const dids = results.map((res) => (typeof res === 'string' ? res : res.did))
const hydrated = await this.profileHydration(dids, {
viewer,
includeSoftDeleted: opts?.includeSoftDeleted,
})
return this.profileBasicPresentation(dids, hydrated, viewer, opts)
return this.profileBasicPresentation(dids, hydrated, viewer)
}

async profilesList(
Expand Down Expand Up @@ -355,9 +355,6 @@ export class ActorViews {
dids: string[],
state: ProfileHydrationState,
viewer: string | null,
opts?: {
omitLabels?: boolean
},
): ProfileViewMap {
const result = this.profilePresentation(dids, state, viewer)
return Object.values(result).reduce((acc, prof) => {
Expand All @@ -367,7 +364,7 @@ export class ActorViews {
displayName: prof.displayName,
avatar: prof.avatar,
viewer: prof.viewer,
labels: opts?.omitLabels ? undefined : prof.labels,
labels: prof.labels,
}
acc[prof.did] = profileBasic
return acc
Expand Down
39 changes: 34 additions & 5 deletions packages/pds/tests/proxied/__snapshots__/views.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,24 @@ Array [
"did": "user(0)",
"displayName": "ali",
"handle": "alice.test",
"labels": Array [
Object {
"cid": "cids(1)",
"cts": "1970-01-01T00:00:00.000Z",
"neg": false,
"src": "user(0)",
"uri": "record(0)",
"val": "self-label-a",
},
Object {
"cid": "cids(1)",
"cts": "1970-01-01T00:00:00.000Z",
"neg": false,
"src": "user(0)",
"uri": "record(0)",
"val": "self-label-b",
},
],
"viewer": Object {
"blockedBy": false,
"muted": false,
Expand All @@ -214,29 +232,40 @@ Array [
"did": "user(2)",
"displayName": "bobby",
"handle": "bob.test",
"labels": Array [],
"viewer": Object {
"blockedBy": false,
"followedBy": "record(1)",
"following": "record(0)",
"followedBy": "record(2)",
"following": "record(1)",
"muted": false,
},
},
Object {
"did": "user(4)",
"handle": "carol.test",
"labels": Array [],
"viewer": Object {
"blockedBy": false,
"followedBy": "record(3)",
"following": "record(2)",
"followedBy": "record(4)",
"following": "record(3)",
"muted": false,
},
},
Object {
"did": "user(5)",
"handle": "dan.test",
"labels": Array [
Object {
"cts": "1970-01-01T00:00:00.000Z",
"neg": false,
"src": "did:example:labeler",
"uri": "user(5)",
"val": "repo-action-label",
},
],
"viewer": Object {
"blockedBy": false,
"following": "record(4)",
"following": "record(5)",
"muted": false,
},
},
Expand Down

0 comments on commit 842e183

Please sign in to comment.