Fix hashtag author filter failing for DIDs (#10772)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -121,7 +121,9 @@ export default function HashtagScreen({
|
|||||||
<Layout.Header.TitleText>{headerTitle}</Layout.Header.TitleText>
|
<Layout.Header.TitleText>{headerTitle}</Layout.Header.TitleText>
|
||||||
{author && (
|
{author && (
|
||||||
<Layout.Header.SubtitleText>
|
<Layout.Header.SubtitleText>
|
||||||
{_(msg`From @${sanitizedAuthor}`)}
|
{author.startsWith('did:')
|
||||||
|
? _(msg`From ${sanitizedAuthor}`)
|
||||||
|
: _(msg`From @${sanitizedAuthor}`)}
|
||||||
</Layout.Header.SubtitleText>
|
</Layout.Header.SubtitleText>
|
||||||
)}
|
)}
|
||||||
</Layout.Header.Content>
|
</Layout.Header.Content>
|
||||||
@@ -172,11 +174,9 @@ function HashtagScreenTab({
|
|||||||
const isCashtag = fullTag.startsWith('$')
|
const isCashtag = fullTag.startsWith('$')
|
||||||
|
|
||||||
const queryParam = useMemo(() => {
|
const queryParam = useMemo(() => {
|
||||||
// Cashtags need # prefix for search: "#$BTC" or "#$BTC from:author"
|
// Cashtags need # prefix for search: "#$BTC"
|
||||||
const searchTag = isCashtag ? `#${fullTag}` : fullTag
|
return isCashtag ? `#${fullTag}` : fullTag
|
||||||
if (!author) return searchTag
|
}, [fullTag, isCashtag])
|
||||||
return `${searchTag} from:${author}`
|
|
||||||
}, [fullTag, author, isCashtag])
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data,
|
data,
|
||||||
@@ -188,7 +188,7 @@ function HashtagScreenTab({
|
|||||||
refetch,
|
refetch,
|
||||||
fetchNextPage,
|
fetchNextPage,
|
||||||
hasNextPage,
|
hasNextPage,
|
||||||
} = useSearchPostsQuery({query: queryParam, sort, enabled: active})
|
} = useSearchPostsQuery({query: queryParam, sort, enabled: active, author})
|
||||||
|
|
||||||
const posts = useMemo(() => {
|
const posts = useMemo(() => {
|
||||||
return data?.pages.flatMap(page => page.posts) || []
|
return data?.pages.flatMap(page => page.posts) || []
|
||||||
|
|||||||
@@ -22,29 +22,35 @@ import {
|
|||||||
} from './util'
|
} from './util'
|
||||||
|
|
||||||
const searchPostsQueryKeyRoot = 'search-posts'
|
const searchPostsQueryKeyRoot = 'search-posts'
|
||||||
const searchPostsQueryKey = ({query, sort}: {query: string; sort?: string}) => [
|
const searchPostsQueryKey = ({
|
||||||
searchPostsQueryKeyRoot,
|
|
||||||
query,
|
query,
|
||||||
sort,
|
sort,
|
||||||
]
|
author,
|
||||||
|
}: {
|
||||||
|
query: string
|
||||||
|
sort?: string
|
||||||
|
author?: string
|
||||||
|
}) => [searchPostsQueryKeyRoot, query, sort, author]
|
||||||
|
|
||||||
export function useSearchPostsQuery({
|
export function useSearchPostsQuery({
|
||||||
query,
|
query,
|
||||||
sort,
|
sort,
|
||||||
enabled,
|
enabled,
|
||||||
|
author,
|
||||||
}: {
|
}: {
|
||||||
query: string
|
query: string
|
||||||
sort?: 'top' | 'latest'
|
sort?: 'top' | 'latest'
|
||||||
enabled?: boolean
|
enabled?: boolean
|
||||||
|
author?: string
|
||||||
}) {
|
}) {
|
||||||
const agent = useAgent()
|
const agent = useAgent()
|
||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
const selectArgs = useMemo(
|
const selectArgs = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
isSearchingSpecificUser: /from:(\w+)/.test(query),
|
isSearchingSpecificUser: !!author || /from:(\w+)/.test(query),
|
||||||
moderationOpts,
|
moderationOpts,
|
||||||
}),
|
}),
|
||||||
[query, moderationOpts],
|
[query, author, moderationOpts],
|
||||||
)
|
)
|
||||||
const lastRun = useRef<{
|
const lastRun = useRef<{
|
||||||
data: InfiniteData<AppBskyFeedSearchPosts.OutputSchema>
|
data: InfiniteData<AppBskyFeedSearchPosts.OutputSchema>
|
||||||
@@ -59,13 +65,14 @@ export function useSearchPostsQuery({
|
|||||||
QueryKey,
|
QueryKey,
|
||||||
string | undefined
|
string | undefined
|
||||||
>({
|
>({
|
||||||
queryKey: searchPostsQueryKey({query, sort}),
|
queryKey: searchPostsQueryKey({query, sort, author}),
|
||||||
queryFn: async ({pageParam}) => {
|
queryFn: async ({pageParam}) => {
|
||||||
const res = await agent.app.bsky.feed.searchPosts({
|
const res = await agent.app.bsky.feed.searchPosts({
|
||||||
q: query,
|
q: query,
|
||||||
limit: 25,
|
limit: 25,
|
||||||
cursor: pageParam,
|
cursor: pageParam,
|
||||||
sort,
|
sort,
|
||||||
|
author,
|
||||||
})
|
})
|
||||||
return res.data
|
return res.data
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user