From 842e1839259a903d3e82aa2662c7c727901dba3a Mon Sep 17 00:00:00 2001 From: devin ivy Date: Wed, 6 Dec 2023 19:21:06 -0500 Subject: [PATCH] Add labels to actor search typeahead results (#1940) add labels to appview actor search typeahead --- .../app/bsky/actor/searchActorsTypeahead.ts | 2 +- packages/bsky/src/services/actor/views.ts | 9 ++--- .../proxied/__snapshots__/views.test.ts.snap | 39 ++++++++++++++++--- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/packages/bsky/src/api/app/bsky/actor/searchActorsTypeahead.ts b/packages/bsky/src/api/app/bsky/actor/searchActorsTypeahead.ts index ff674edf898..da612edcc87 100644 --- a/packages/bsky/src/api/app/bsky/actor/searchActorsTypeahead.ts +++ b/packages/bsky/src/api/app/bsky/actor/searchActorsTypeahead.ts @@ -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) => { diff --git a/packages/bsky/src/services/actor/views.ts b/packages/bsky/src/services/actor/views.ts index b60dcedcbaf..32e267a8868 100644 --- a/packages/bsky/src/services/actor/views.ts +++ b/packages/bsky/src/services/actor/views.ts @@ -57,7 +57,7 @@ export class ActorViews { async profilesBasic( results: (ActorResult | string)[], viewer: string | null, - opts?: { omitLabels?: boolean; includeSoftDeleted?: boolean }, + opts?: { includeSoftDeleted?: boolean }, ): Promise { if (results.length === 0) return {} const dids = results.map((res) => (typeof res === 'string' ? res : res.did)) @@ -65,7 +65,7 @@ export class ActorViews { viewer, includeSoftDeleted: opts?.includeSoftDeleted, }) - return this.profileBasicPresentation(dids, hydrated, viewer, opts) + return this.profileBasicPresentation(dids, hydrated, viewer) } async profilesList( @@ -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) => { @@ -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 diff --git a/packages/pds/tests/proxied/__snapshots__/views.test.ts.snap b/packages/pds/tests/proxied/__snapshots__/views.test.ts.snap index f856407ccbc..165257220d2 100644 --- a/packages/pds/tests/proxied/__snapshots__/views.test.ts.snap +++ b/packages/pds/tests/proxied/__snapshots__/views.test.ts.snap @@ -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, @@ -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, }, },