dont filter exact matches from typeahead (#4802)
parent
3627a249ff
commit
59bafb426f
|
@ -45,9 +45,13 @@ export function useActorAutocompleteQuery(
|
||||||
},
|
},
|
||||||
select: React.useCallback(
|
select: React.useCallback(
|
||||||
(data: AppBskyActorDefs.ProfileViewBasic[]) => {
|
(data: AppBskyActorDefs.ProfileViewBasic[]) => {
|
||||||
return computeSuggestions(data, moderationOpts || DEFAULT_MOD_OPTS)
|
return computeSuggestions({
|
||||||
|
q: prefix,
|
||||||
|
searched: data,
|
||||||
|
moderationOpts: moderationOpts || DEFAULT_MOD_OPTS,
|
||||||
|
})
|
||||||
},
|
},
|
||||||
[moderationOpts],
|
[prefix, moderationOpts],
|
||||||
),
|
),
|
||||||
placeholderData: maintainData ? keepPreviousData : undefined,
|
placeholderData: maintainData ? keepPreviousData : undefined,
|
||||||
})
|
})
|
||||||
|
@ -81,19 +85,25 @@ export function useActorAutocompleteFn() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return computeSuggestions(
|
return computeSuggestions({
|
||||||
res?.data.actors,
|
q: query,
|
||||||
moderationOpts || DEFAULT_MOD_OPTS,
|
searched: res?.data.actors,
|
||||||
)
|
moderationOpts: moderationOpts || DEFAULT_MOD_OPTS,
|
||||||
|
})
|
||||||
},
|
},
|
||||||
[queryClient, moderationOpts, agent],
|
[queryClient, moderationOpts, agent],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function computeSuggestions(
|
function computeSuggestions({
|
||||||
searched: AppBskyActorDefs.ProfileViewBasic[] = [],
|
q,
|
||||||
moderationOpts: ModerationOpts,
|
searched = [],
|
||||||
) {
|
moderationOpts,
|
||||||
|
}: {
|
||||||
|
q?: string
|
||||||
|
searched?: AppBskyActorDefs.ProfileViewBasic[]
|
||||||
|
moderationOpts: ModerationOpts
|
||||||
|
}) {
|
||||||
let items: AppBskyActorDefs.ProfileViewBasic[] = []
|
let items: AppBskyActorDefs.ProfileViewBasic[] = []
|
||||||
for (const item of searched) {
|
for (const item of searched) {
|
||||||
if (!items.find(item2 => item2.handle === item.handle)) {
|
if (!items.find(item2 => item2.handle === item.handle)) {
|
||||||
|
@ -102,6 +112,7 @@ function computeSuggestions(
|
||||||
}
|
}
|
||||||
return items.filter(profile => {
|
return items.filter(profile => {
|
||||||
const modui = moderateProfile(profile, moderationOpts).ui('profileList')
|
const modui = moderateProfile(profile, moderationOpts).ui('profileList')
|
||||||
return !modui.filter || isJustAMute(modui)
|
const isExactMatch = q && profile.handle.toLowerCase() === q
|
||||||
|
return isExactMatch || !modui.filter || isJustAMute(modui)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue