mirror of https://github.com/tooot-app/app
Fix #661
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:
parent
8814161e0e
commit
9a289489fa
|
@ -38,6 +38,7 @@ const ComposeRootSuggestions: React.FC = () => {
|
||||||
const { isFetching, data, refetch } = useSearchQuery({
|
const { isFetching, data, refetch } = useSearchQuery({
|
||||||
type: mapSchemaToType(),
|
type: mapSchemaToType(),
|
||||||
term: composeState.tag?.raw.substring(1),
|
term: composeState.tag?.raw.substring(1),
|
||||||
|
...(mapSchemaToType() === 'accounts' && { following: true }),
|
||||||
options: { enabled: false }
|
options: { enabled: false }
|
||||||
})
|
})
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
@ -275,7 +275,7 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
flRef.current?.scrollToIndex({
|
flRef.current?.scrollToIndex({
|
||||||
index: (ancestorsCache.current?.length || 0),
|
index: ancestorsCache.current?.length || 0,
|
||||||
viewOffset: 50
|
viewOffset: 50
|
||||||
})
|
})
|
||||||
}, 50)
|
}, 50)
|
||||||
|
|
|
@ -9,6 +9,7 @@ export type QueryKeySearch = [
|
||||||
type?: 'accounts' | 'hashtags' | 'statuses'
|
type?: 'accounts' | 'hashtags' | 'statuses'
|
||||||
term?: string
|
term?: string
|
||||||
limit?: number
|
limit?: number
|
||||||
|
following?: boolean
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -19,7 +20,7 @@ export type SearchResult = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const queryFunction = async ({ queryKey, meta }: QueryFunctionContext<QueryKeySearch>) => {
|
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) {
|
if (!term?.length) {
|
||||||
return Promise.reject('Empty search term')
|
return Promise.reject('Empty search term')
|
||||||
}
|
}
|
||||||
|
@ -31,7 +32,8 @@ const queryFunction = async ({ queryKey, meta }: QueryFunctionContext<QueryKeySe
|
||||||
q: term,
|
q: term,
|
||||||
...(type && { type }),
|
...(type && { type }),
|
||||||
limit,
|
limit,
|
||||||
resolve: true
|
resolve: true,
|
||||||
|
following
|
||||||
},
|
},
|
||||||
...(meta && { extras: meta })
|
...(meta && { extras: meta })
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue