The API does not support a better way to achieve this as suggested. Though the search API accepts a "following" param, and it will return data prioritising following accounts.
This commit is contained in:
xmflsct 2023-01-15 19:38:45 +01:00
parent 8814161e0e
commit 9a289489fa
3 changed files with 6 additions and 3 deletions

View File

@ -38,6 +38,7 @@ const ComposeRootSuggestions: React.FC = () => {
const { isFetching, data, refetch } = useSearchQuery({
type: mapSchemaToType(),
term: composeState.tag?.raw.substring(1),
...(mapSchemaToType() === 'accounts' && { following: true }),
options: { enabled: false }
})
useEffect(() => {

View File

@ -275,7 +275,7 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
setTimeout(() => {
flRef.current?.scrollToIndex({
index: (ancestorsCache.current?.length || 0),
index: ancestorsCache.current?.length || 0,
viewOffset: 50
})
}, 50)

View File

@ -9,6 +9,7 @@ export type QueryKeySearch = [
type?: 'accounts' | 'hashtags' | 'statuses'
term?: string
limit?: number
following?: boolean
}
]
@ -19,7 +20,7 @@ export type SearchResult = {
}
const queryFunction = async ({ queryKey, meta }: QueryFunctionContext<QueryKeySearch>) => {
const { type, term, limit = 10 } = queryKey[1]
const { type, term, limit = 10, following = false } = queryKey[1]
if (!term?.length) {
return Promise.reject('Empty search term')
}
@ -31,7 +32,8 @@ const queryFunction = async ({ queryKey, meta }: QueryFunctionContext<QueryKeySe
q: term,
...(type && { type }),
limit,
resolve: true
resolve: true,
following
},
...(meta && { extras: meta })
})