Special-case 'me' values in search queries (#11043)
This commit is contained in:
@@ -319,18 +319,18 @@ let SearchScreenPostResults = ({
|
||||
}): React.ReactNode => {
|
||||
const ax = useAnalytics()
|
||||
const {t: l} = useLingui()
|
||||
const {currentAccount, hasSession} = useSession()
|
||||
const {hasSession} = useSession()
|
||||
const [isPTR, setIsPTR] = useState(false)
|
||||
const trackPostView = usePostViewTracking('SearchResults')
|
||||
|
||||
const searchV2Enabled = ax.features.enabled(ax.features.SearchV2Enable)
|
||||
|
||||
const augmentedV2Query = useMemo(() => {
|
||||
return augmentSearchQuery(query || '', {did: currentAccount?.did})
|
||||
}, [query, currentAccount])
|
||||
return augmentSearchQuery(query || '')
|
||||
}, [query])
|
||||
const augmentedV1Query = useMemo(() => {
|
||||
return augmentSearchQuery(queryWithParams || '', {did: currentAccount?.did})
|
||||
}, [queryWithParams, currentAccount])
|
||||
return augmentSearchQuery(queryWithParams || '')
|
||||
}, [queryWithParams])
|
||||
|
||||
/*
|
||||
* Both hooks are called to keep hook order stable; `enabled` ensures only the
|
||||
|
||||
@@ -73,6 +73,12 @@ describe(`AdvancedSearchDialog serialize/parse`, () => {
|
||||
expect(state.until).toBe('2024-02-01')
|
||||
})
|
||||
|
||||
it(`keeps from:me in the query box rather than lifting it into a row`, () => {
|
||||
const state = parseAdvancedSearch('from:me', {})
|
||||
expect(state.query).toBe('from:me')
|
||||
expect(state.filters.find(f => f.field === 'authors')).toBeUndefined()
|
||||
})
|
||||
|
||||
it(`merges a query-box operator with the matching filter param`, () => {
|
||||
const state = parseAdvancedSearch('hi from:bob', {author: 'alice'})
|
||||
expect(state.query).toBe('hi')
|
||||
|
||||
@@ -5,7 +5,6 @@ import {augmentSearchQuery} from '#/lib/strings/helpers'
|
||||
import {codeToLanguageName} from '#/locale/helpers'
|
||||
import {useLanguagePrefs} from '#/state/preferences/languages'
|
||||
import {useSearchPostsV2Query} from '#/state/queries/search-posts-v2'
|
||||
import {useSession} from '#/state/session'
|
||||
import {type SearchFilters} from '#/screens/Search/searchParams'
|
||||
import {Admonition} from '#/components/Admonition'
|
||||
import {createStaticClick, InlineLinkText} from '#/components/Link'
|
||||
@@ -34,12 +33,8 @@ export function DetectedLanguagesAdmonition({
|
||||
onPressLanguage: (code: string) => void
|
||||
}) {
|
||||
const {appLanguage} = useLanguagePrefs()
|
||||
const {currentAccount} = useSession()
|
||||
|
||||
const augmentedQuery = useMemo(
|
||||
() => augmentSearchQuery(query || '', {did: currentAccount?.did}),
|
||||
[query, currentAccount],
|
||||
)
|
||||
const augmentedQuery = useMemo(() => augmentSearchQuery(query || ''), [query])
|
||||
|
||||
const {data} = useSearchPostsV2Query({
|
||||
query: augmentedQuery,
|
||||
|
||||
Reference in New Issue
Block a user