From 9a289489fa720ad4183be5253df721fa63c57633 Mon Sep 17 00:00:00 2001 From: xmflsct Date: Sun, 15 Jan 2023 19:38:45 +0100 Subject: [PATCH] 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. --- src/screens/Compose/Root/Suggestions.tsx | 1 + src/screens/Tabs/Shared/Toot.tsx | 2 +- src/utils/queryHooks/search.ts | 6 ++++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/screens/Compose/Root/Suggestions.tsx b/src/screens/Compose/Root/Suggestions.tsx index 89439541..b5c8b267 100644 --- a/src/screens/Compose/Root/Suggestions.tsx +++ b/src/screens/Compose/Root/Suggestions.tsx @@ -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(() => { diff --git a/src/screens/Tabs/Shared/Toot.tsx b/src/screens/Tabs/Shared/Toot.tsx index 7c791e72..2379b634 100644 --- a/src/screens/Tabs/Shared/Toot.tsx +++ b/src/screens/Tabs/Shared/Toot.tsx @@ -275,7 +275,7 @@ const TabSharedToot: React.FC> = ({ setTimeout(() => { flRef.current?.scrollToIndex({ - index: (ancestorsCache.current?.length || 0), + index: ancestorsCache.current?.length || 0, viewOffset: 50 }) }, 50) diff --git a/src/utils/queryHooks/search.ts b/src/utils/queryHooks/search.ts index 95be0875..4f0ca471 100644 --- a/src/utils/queryHooks/search.ts +++ b/src/utils/queryHooks/search.ts @@ -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) => { - 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