Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
haileyok committed Aug 6, 2024
1 parent 587e6f6 commit b4c76d5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/bsky/src/api/app/bsky/actor/searchActorsTypeahead.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@ const hydration = async (
const noBlocks = (inputs: RulesFnInput<Context, Params, Skeleton>) => {
const { ctx, skeleton, hydration, params } = inputs
skeleton.dids = skeleton.dids.filter((did) => {
// Always display exact matches so that users can find profiles that they have blocked
const actor = hydration.actors?.get(did)
if (!actor) return false
const isExactMatch = actor.handle?.toLowerCase() === params.q?.toLowerCase()
// Always display exact matches so that users can find profiles that they have blocked
const term = (params.q ?? params.term ?? '').toLowerCase()
const isExactMatch = actor.handle?.toLowerCase() === term
return isExactMatch || !ctx.views.viewerBlockExists(did, hydration)
})
return skeleton
Expand Down
22 changes: 20 additions & 2 deletions packages/bsky/tests/views/block-lists.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,21 +295,39 @@ describe('pds views with blocking from block lists', () => {
it('does not return blocked accounts in actor search typeahead', async () => {
const resCarol = await agent.api.app.bsky.actor.searchActorsTypeahead(
{
term: 'dan.test',
term: 'dan.tes',
},
{ headers: await network.serviceHeaders(carol) },
)
expect(resCarol.data.actors.some((actor) => actor.did === dan)).toBeFalsy()

const resDan = await agent.api.app.bsky.actor.searchActorsTypeahead(
{
term: 'carol.test',
term: 'carol.tes',
},
{ headers: await network.serviceHeaders(dan) },
)
expect(resDan.data.actors.some((actor) => actor.did === carol)).toBeFalsy()
})

it('does return blocked accounts in actor search typeahead when term is exact handle', async () => {
const resCarol = await agent.api.app.bsky.actor.searchActorsTypeahead(
{
term: 'dan.test',
},
{ headers: await network.serviceHeaders(carol) },
)
expect(resCarol.data.actors.some((actor) => actor.did === dan)).toBeTruthy()

const resDan = await agent.api.app.bsky.actor.searchActorsTypeahead(
{
term: 'carol.test',
},
{ headers: await network.serviceHeaders(dan) },
)
expect(resDan.data.actors.some((actor) => actor.did === carol)).toBeTruthy()
})

it('does not return blocked accounts in get suggestions', async () => {
// unfollow so they _would_ show up in suggestions if not for block
await sc.unfollow(carol, dan)
Expand Down

0 comments on commit b4c76d5

Please sign in to comment.