Use same search query for starter packs
This commit is contained in:
@@ -8,8 +8,8 @@ import {useA11y} from '#/state/a11y'
|
|||||||
import {DISCOVER_FEED_URI} from 'lib/constants'
|
import {DISCOVER_FEED_URI} from 'lib/constants'
|
||||||
import {
|
import {
|
||||||
useGetPopularFeedsQuery,
|
useGetPopularFeedsQuery,
|
||||||
|
usePopularFeedsSearch,
|
||||||
useSavedFeeds,
|
useSavedFeeds,
|
||||||
useSearchPopularFeedsQuery,
|
|
||||||
} from 'state/queries/feed'
|
} from 'state/queries/feed'
|
||||||
import {SearchInput} from 'view/com/util/forms/SearchInput'
|
import {SearchInput} from 'view/com/util/forms/SearchInput'
|
||||||
import {List} from 'view/com/util/List'
|
import {List} from 'view/com/util/List'
|
||||||
@@ -59,7 +59,7 @@ export function StepFeeds({moderationOpts}: {moderationOpts: ModerationOpts}) {
|
|||||||
: undefined
|
: undefined
|
||||||
|
|
||||||
const {data: searchedFeeds, isFetching: isFetchingSearchedFeeds} =
|
const {data: searchedFeeds, isFetching: isFetchingSearchedFeeds} =
|
||||||
useSearchPopularFeedsQuery({q: throttledQuery})
|
usePopularFeedsSearch({query: throttledQuery})
|
||||||
|
|
||||||
const isLoading =
|
const isLoading =
|
||||||
!isFetchedSavedFeeds || isLoadingPopularFeeds || isFetchingSearchedFeeds
|
!isFetchedSavedFeeds || isLoadingPopularFeeds || isFetchingSearchedFeeds
|
||||||
|
|||||||
@@ -335,30 +335,6 @@ export function useSearchPopularFeedsMutation() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useSearchPopularFeedsQuery({q}: {q: string}) {
|
|
||||||
const agent = useAgent()
|
|
||||||
const moderationOpts = useModerationOpts()
|
|
||||||
return useQuery({
|
|
||||||
enabled: Boolean(moderationOpts),
|
|
||||||
queryKey: ['searchPopularFeeds', q],
|
|
||||||
queryFn: async () => {
|
|
||||||
const res = await agent.app.bsky.unspecced.getPopularFeedGenerators({
|
|
||||||
limit: 15,
|
|
||||||
query: q,
|
|
||||||
})
|
|
||||||
|
|
||||||
return res.data.feeds
|
|
||||||
},
|
|
||||||
placeholderData: keepPreviousData,
|
|
||||||
select(data) {
|
|
||||||
return data.filter(feed => {
|
|
||||||
const decision = moderateFeedGenerator(feed, moderationOpts!)
|
|
||||||
return !decision.ui('contentList').filter
|
|
||||||
})
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const popularFeedsSearchQueryKeyRoot = 'popularFeedsSearch'
|
const popularFeedsSearchQueryKeyRoot = 'popularFeedsSearch'
|
||||||
export const createPopularFeedsSearchQueryKey = (query: string) => [
|
export const createPopularFeedsSearchQueryKey = (query: string) => [
|
||||||
popularFeedsSearchQueryKeyRoot,
|
popularFeedsSearchQueryKeyRoot,
|
||||||
@@ -381,12 +357,13 @@ export function usePopularFeedsSearch({
|
|||||||
queryKey: createPopularFeedsSearchQueryKey(query),
|
queryKey: createPopularFeedsSearchQueryKey(query),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const res = await agent.app.bsky.unspecced.getPopularFeedGenerators({
|
const res = await agent.app.bsky.unspecced.getPopularFeedGenerators({
|
||||||
limit: 10,
|
limit: 15,
|
||||||
query: query,
|
query: query,
|
||||||
})
|
})
|
||||||
|
|
||||||
return res.data.feeds
|
return res.data.feeds
|
||||||
},
|
},
|
||||||
|
placeholderData: keepPreviousData,
|
||||||
select(data) {
|
select(data) {
|
||||||
return data.filter(feed => {
|
return data.filter(feed => {
|
||||||
const decision = moderateFeedGenerator(feed, moderationOpts!)
|
const decision = moderateFeedGenerator(feed, moderationOpts!)
|
||||||
|
|||||||
Reference in New Issue
Block a user