Add search event analytics (#9949)
Co-authored-by: Eric Bailey <git@esb.lol>
This commit is contained in:
@@ -649,6 +649,32 @@ export type Events = {
|
|||||||
tab: string
|
tab: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
'search:query': {
|
||||||
|
source: 'typed' | 'history' | 'autocomplete'
|
||||||
|
}
|
||||||
|
|
||||||
|
'search:results:loaded': {
|
||||||
|
tab: 'top' | 'latest' | 'people' | 'feeds'
|
||||||
|
initialCount: number
|
||||||
|
}
|
||||||
|
|
||||||
|
'search:result:press': {
|
||||||
|
tab?: 'top' | 'latest' | 'people' | 'feeds'
|
||||||
|
resultType: 'post' | 'profile' | 'feed'
|
||||||
|
position: number
|
||||||
|
uri: string
|
||||||
|
}
|
||||||
|
|
||||||
|
'search:recent:press': {
|
||||||
|
profileDid: string
|
||||||
|
position: number
|
||||||
|
}
|
||||||
|
|
||||||
|
'search:autocomplete:press': {
|
||||||
|
profileDid: string
|
||||||
|
position: number
|
||||||
|
}
|
||||||
|
|
||||||
'progressGuide:hide': {}
|
'progressGuide:hide': {}
|
||||||
'progressGuide:followDialog:open': {}
|
'progressGuide:followDialog:open': {}
|
||||||
|
|
||||||
|
|||||||
+23
-25
@@ -1,4 +1,4 @@
|
|||||||
import React, {useMemo} from 'react'
|
import {useCallback, useEffect, useMemo} from 'react'
|
||||||
import {type GestureResponderEvent, View} from 'react-native'
|
import {type GestureResponderEvent, View} from 'react-native'
|
||||||
import {
|
import {
|
||||||
type AppBskyFeedDefs,
|
type AppBskyFeedDefs,
|
||||||
@@ -6,9 +6,7 @@ import {
|
|||||||
AtUri,
|
AtUri,
|
||||||
RichText as RichTextApi,
|
RichText as RichTextApi,
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
import {msg} from '@lingui/core/macro'
|
import {Plural, Trans, useLingui} from '@lingui/react/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
|
||||||
import {Plural, Trans} from '@lingui/react/macro'
|
|
||||||
import {useQueryClient} from '@tanstack/react-query'
|
import {useQueryClient} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {sanitizeHandle} from '#/lib/strings/handles'
|
import {sanitizeHandle} from '#/lib/strings/handles'
|
||||||
@@ -73,11 +71,11 @@ export function Link({
|
|||||||
}: Props & Omit<LinkProps, 'to' | 'label'>) {
|
}: Props & Omit<LinkProps, 'to' | 'label'>) {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
const href = React.useMemo(() => {
|
const href = useMemo(() => {
|
||||||
return createProfileFeedHref({feed: view})
|
return createProfileFeedHref({feed: view})
|
||||||
}, [view])
|
}, [view])
|
||||||
|
|
||||||
React.useEffect(() => {
|
useEffect(() => {
|
||||||
precacheFeedFromGeneratorView(queryClient, view)
|
precacheFeedFromGeneratorView(queryClient, view)
|
||||||
}, [view, queryClient])
|
}, [view, queryClient])
|
||||||
|
|
||||||
@@ -212,7 +210,7 @@ export function Description({
|
|||||||
description,
|
description,
|
||||||
...rest
|
...rest
|
||||||
}: {description?: string} & Partial<RichTextProps>) {
|
}: {description?: string} & Partial<RichTextProps>) {
|
||||||
const rt = React.useMemo(() => {
|
const rt = useMemo(() => {
|
||||||
if (!description) return
|
if (!description) return
|
||||||
const rt = new RichTextApi({text: description || ''})
|
const rt = new RichTextApi({text: description || ''})
|
||||||
rt.detectFacetsWithoutResolution()
|
rt.detectFacetsWithoutResolution()
|
||||||
@@ -279,7 +277,7 @@ function SaveButtonInner({
|
|||||||
pin?: boolean
|
pin?: boolean
|
||||||
text?: boolean
|
text?: boolean
|
||||||
} & Partial<ButtonProps>) {
|
} & Partial<ButtonProps>) {
|
||||||
const {_} = useLingui()
|
const {t: l} = useLingui()
|
||||||
const {data: preferences} = usePreferencesQuery()
|
const {data: preferences} = usePreferencesQuery()
|
||||||
const {isPending: isAddSavedFeedPending, mutateAsync: saveFeeds} =
|
const {isPending: isAddSavedFeedPending, mutateAsync: saveFeeds} =
|
||||||
useAddSavedFeedsMutation()
|
useAddSavedFeedsMutation()
|
||||||
@@ -289,13 +287,13 @@ function SaveButtonInner({
|
|||||||
const uri = view.uri
|
const uri = view.uri
|
||||||
const type = view.uri.includes('app.bsky.feed.generator') ? 'feed' : 'list'
|
const type = view.uri.includes('app.bsky.feed.generator') ? 'feed' : 'list'
|
||||||
|
|
||||||
const savedFeedConfig = React.useMemo(() => {
|
const savedFeedConfig = useMemo(() => {
|
||||||
return preferences?.savedFeeds?.find(feed => feed.value === uri)
|
return preferences?.savedFeeds?.find(feed => feed.value === uri)
|
||||||
}, [preferences?.savedFeeds, uri])
|
}, [preferences?.savedFeeds, uri])
|
||||||
const removePromptControl = Prompt.usePromptControl()
|
const removePromptControl = Prompt.usePromptControl()
|
||||||
const isPending = isAddSavedFeedPending || isRemovePending
|
const isPending = isAddSavedFeedPending || isRemovePending
|
||||||
|
|
||||||
const toggleSave = React.useCallback(
|
const toggleSave = useCallback(
|
||||||
async (e: GestureResponderEvent) => {
|
async (e: GestureResponderEvent) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
@@ -312,17 +310,17 @@ function SaveButtonInner({
|
|||||||
},
|
},
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
Toast.show(_(msg({message: 'Feeds updated!', context: 'toast'})))
|
Toast.show(l({message: 'Feeds updated!', context: 'toast'}))
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
logger.error(err, {message: `FeedCard: failed to update feeds`, pin})
|
logger.error(err, {message: `FeedCard: failed to update feeds`, pin})
|
||||||
Toast.show(_(msg`Failed to update feeds`), 'xmark')
|
Toast.show(l`Failed to update feeds`, 'xmark')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[_, pin, saveFeeds, removeFeed, uri, savedFeedConfig, type],
|
[l, pin, saveFeeds, removeFeed, uri, savedFeedConfig, type],
|
||||||
)
|
)
|
||||||
|
|
||||||
const onPrompRemoveFeed = React.useCallback(
|
const onPromptRemoveFeed = useCallback(
|
||||||
async (e: GestureResponderEvent) => {
|
(e: GestureResponderEvent) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
|
|
||||||
@@ -335,11 +333,13 @@ function SaveButtonInner({
|
|||||||
<>
|
<>
|
||||||
<Button
|
<Button
|
||||||
disabled={isPending}
|
disabled={isPending}
|
||||||
label={_(msg`Add this feed to your feeds`)}
|
label={l`Add this feed to your feeds`}
|
||||||
size="small"
|
size="small"
|
||||||
variant="solid"
|
variant="solid"
|
||||||
color={savedFeedConfig ? 'secondary' : 'primary'}
|
color={savedFeedConfig ? 'secondary' : 'primary'}
|
||||||
onPress={savedFeedConfig ? onPrompRemoveFeed : toggleSave}
|
onPress={(e: GestureResponderEvent) =>
|
||||||
|
savedFeedConfig ? onPromptRemoveFeed(e) : void toggleSave(e)
|
||||||
|
}
|
||||||
{...buttonProps}>
|
{...buttonProps}>
|
||||||
{savedFeedConfig ? (
|
{savedFeedConfig ? (
|
||||||
<>
|
<>
|
||||||
@@ -350,7 +350,7 @@ function SaveButtonInner({
|
|||||||
)}
|
)}
|
||||||
{text && (
|
{text && (
|
||||||
<ButtonText>
|
<ButtonText>
|
||||||
<Trans>Unpin Feed</Trans>
|
<Trans>Unpin feed</Trans>
|
||||||
</ButtonText>
|
</ButtonText>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
@@ -359,7 +359,7 @@ function SaveButtonInner({
|
|||||||
<ButtonIcon size="md" icon={isPending ? Loader : PinIcon} />
|
<ButtonIcon size="md" icon={isPending ? Loader : PinIcon} />
|
||||||
{text && (
|
{text && (
|
||||||
<ButtonText>
|
<ButtonText>
|
||||||
<Trans>Pin Feed</Trans>
|
<Trans>Pin feed</Trans>
|
||||||
</ButtonText>
|
</ButtonText>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
@@ -368,12 +368,10 @@ function SaveButtonInner({
|
|||||||
|
|
||||||
<Prompt.Basic
|
<Prompt.Basic
|
||||||
control={removePromptControl}
|
control={removePromptControl}
|
||||||
title={_(msg`Remove from your feeds?`)}
|
title={l`Remove from your feeds?`}
|
||||||
description={_(
|
description={l`Are you sure you want to remove this from your feeds?`}
|
||||||
msg`Are you sure you want to remove this from your feeds?`,
|
onConfirm={(e: GestureResponderEvent) => void toggleSave(e)}
|
||||||
)}
|
confirmButtonCta={l`Remove`}
|
||||||
onConfirm={toggleSave}
|
|
||||||
confirmButtonCta={_(msg`Remove`)}
|
|
||||||
confirmButtonColor="negative"
|
confirmButtonColor="negative"
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ import {
|
|||||||
type ModerationOpts,
|
type ModerationOpts,
|
||||||
RichText as RichTextApi,
|
RichText as RichTextApi,
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
import {msg} from '@lingui/core/macro'
|
import {useLingui} from '@lingui/react/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
|
||||||
|
|
||||||
import {getModerationCauseKey} from '#/lib/moderation'
|
import {getModerationCauseKey} from '#/lib/moderation'
|
||||||
import {forceLTR} from '#/lib/strings/bidi'
|
import {forceLTR} from '#/lib/strings/bidi'
|
||||||
@@ -56,6 +55,7 @@ export function Default({
|
|||||||
testID,
|
testID,
|
||||||
position,
|
position,
|
||||||
contextProfileDid,
|
contextProfileDid,
|
||||||
|
onPress,
|
||||||
}: {
|
}: {
|
||||||
profile: bsky.profile.AnyProfileView
|
profile: bsky.profile.AnyProfileView
|
||||||
moderationOpts: ModerationOpts
|
moderationOpts: ModerationOpts
|
||||||
@@ -63,9 +63,10 @@ export function Default({
|
|||||||
testID?: string
|
testID?: string
|
||||||
position?: number
|
position?: number
|
||||||
contextProfileDid?: string
|
contextProfileDid?: string
|
||||||
|
onPress?: (e: GestureResponderEvent) => void
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Link testID={testID} profile={profile}>
|
<Link testID={testID} profile={profile} onPress={onPress}>
|
||||||
<Card
|
<Card
|
||||||
profile={profile}
|
profile={profile}
|
||||||
moderationOpts={moderationOpts}
|
moderationOpts={moderationOpts}
|
||||||
@@ -135,14 +136,13 @@ export function Link({
|
|||||||
}: {
|
}: {
|
||||||
profile: bsky.profile.AnyProfileView
|
profile: bsky.profile.AnyProfileView
|
||||||
} & Omit<LinkProps, 'to' | 'label'>) {
|
} & Omit<LinkProps, 'to' | 'label'>) {
|
||||||
const {_} = useLingui()
|
const {t: l} = useLingui()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<InternalLink
|
<InternalLink
|
||||||
label={_(
|
label={l`View ${
|
||||||
msg`View ${
|
profile.displayName || sanitizeHandle(profile.handle)
|
||||||
profile.displayName || sanitizeHandle(profile.handle)
|
}’s profile`}
|
||||||
}'s profile`,
|
|
||||||
)}
|
|
||||||
to={{
|
to={{
|
||||||
screen: 'Profile',
|
screen: 'Profile',
|
||||||
params: {name: profile.did},
|
params: {name: profile.did},
|
||||||
@@ -488,7 +488,7 @@ export function FollowButtonInner({
|
|||||||
contextProfileDid,
|
contextProfileDid,
|
||||||
...rest
|
...rest
|
||||||
}: FollowButtonProps) {
|
}: FollowButtonProps) {
|
||||||
const {_} = useLingui()
|
const {t: l} = useLingui()
|
||||||
const profile = useProfileShadow(profileUnshadowed)
|
const profile = useProfileShadow(profileUnshadowed)
|
||||||
const moderation = moderateProfile(profile, moderationOpts)
|
const moderation = moderateProfile(profile, moderationOpts)
|
||||||
const [queueFollow, queueUnfollow] = useProfileFollowMutationQueue(
|
const [queueFollow, queueUnfollow] = useProfileFollowMutationQueue(
|
||||||
@@ -505,18 +505,17 @@ export function FollowButtonInner({
|
|||||||
try {
|
try {
|
||||||
await queueFollow()
|
await queueFollow()
|
||||||
Toast.show(
|
Toast.show(
|
||||||
_(
|
l`Following ${sanitizeDisplayName(
|
||||||
msg`Following ${sanitizeDisplayName(
|
profile.displayName || profile.handle,
|
||||||
profile.displayName || profile.handle,
|
moderation.ui('displayName'),
|
||||||
moderation.ui('displayName'),
|
)}`,
|
||||||
)}`,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
onPressProp?.(e)
|
onPressProp?.(e)
|
||||||
onFollow?.()
|
onFollow?.()
|
||||||
} catch (err: any) {
|
} catch (e) {
|
||||||
|
const err = e as Error
|
||||||
if (err?.name !== 'AbortError') {
|
if (err?.name !== 'AbortError') {
|
||||||
Toast.show(_(msg`An issue occurred, please try again.`), 'xmark')
|
Toast.show(l`An issue occurred, please try again.`, 'xmark')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -527,40 +526,33 @@ export function FollowButtonInner({
|
|||||||
try {
|
try {
|
||||||
await queueUnfollow()
|
await queueUnfollow()
|
||||||
Toast.show(
|
Toast.show(
|
||||||
_(
|
l`No longer following ${sanitizeDisplayName(
|
||||||
msg`No longer following ${sanitizeDisplayName(
|
profile.displayName || profile.handle,
|
||||||
profile.displayName || profile.handle,
|
moderation.ui('displayName'),
|
||||||
moderation.ui('displayName'),
|
)}`,
|
||||||
)}`,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
onPressProp?.(e)
|
onPressProp?.(e)
|
||||||
} catch (err: any) {
|
} catch (e) {
|
||||||
|
const err = e as Error
|
||||||
if (err?.name !== 'AbortError') {
|
if (err?.name !== 'AbortError') {
|
||||||
Toast.show(_(msg`An issue occurred, please try again.`), 'xmark')
|
Toast.show(l`An issue occurred, please try again.`, 'xmark')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const unfollowLabel = _(
|
const unfollowLabel = l({
|
||||||
msg({
|
message: 'Following',
|
||||||
message: 'Following',
|
comment: 'User is following this account, click to unfollow',
|
||||||
comment: 'User is following this account, click to unfollow',
|
})
|
||||||
}),
|
|
||||||
)
|
|
||||||
const followLabel = profile.viewer?.followedBy
|
const followLabel = profile.viewer?.followedBy
|
||||||
? _(
|
? l({
|
||||||
msg({
|
message: 'Follow back',
|
||||||
message: 'Follow back',
|
comment: 'User is not following this account, click to follow back',
|
||||||
comment: 'User is not following this account, click to follow back',
|
})
|
||||||
}),
|
: l({
|
||||||
)
|
message: 'Follow',
|
||||||
: _(
|
comment: 'User is not following this account, click to follow',
|
||||||
msg({
|
})
|
||||||
message: 'Follow',
|
|
||||||
comment: 'User is not following this account, click to follow',
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
|
|
||||||
if (!profile.viewer) return null
|
if (!profile.viewer) return null
|
||||||
if (
|
if (
|
||||||
@@ -579,7 +571,9 @@ export function FollowButtonInner({
|
|||||||
variant="solid"
|
variant="solid"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
{...rest}
|
{...rest}
|
||||||
onPress={onPressUnfollow}>
|
onPress={(e: GestureResponderEvent) => {
|
||||||
|
void onPressUnfollow(e)
|
||||||
|
}}>
|
||||||
{withIcon && (
|
{withIcon && (
|
||||||
<ButtonIcon icon={Check} position={isRound ? undefined : 'left'} />
|
<ButtonIcon icon={Check} position={isRound ? undefined : 'left'} />
|
||||||
)}
|
)}
|
||||||
@@ -592,7 +586,9 @@ export function FollowButtonInner({
|
|||||||
variant="solid"
|
variant="solid"
|
||||||
color={colorInverted ? 'secondary_inverted' : 'primary'}
|
color={colorInverted ? 'secondary_inverted' : 'primary'}
|
||||||
{...rest}
|
{...rest}
|
||||||
onPress={onPressFollow}>
|
onPress={(e: GestureResponderEvent) => {
|
||||||
|
void onPressFollow(e)
|
||||||
|
}}>
|
||||||
{withIcon && (
|
{withIcon && (
|
||||||
<ButtonIcon icon={Plus} position={isRound ? undefined : 'left'} />
|
<ButtonIcon icon={Plus} position={isRound ? undefined : 'left'} />
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import React from 'react'
|
import {forwardRef} from 'react'
|
||||||
import {type TextInput, View} from 'react-native'
|
import {type TextInput, View} from 'react-native'
|
||||||
import {msg} from '@lingui/core/macro'
|
import {useLingui} from '@lingui/react/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
|
||||||
|
|
||||||
import {HITSLOP_10} from '#/lib/constants'
|
import {HITSLOP_10} from '#/lib/constants'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
@@ -19,10 +18,10 @@ type SearchInputProps = Omit<TextField.InputProps, 'label'> & {
|
|||||||
onClearText?: () => void
|
onClearText?: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SearchInput = React.forwardRef<TextInput, SearchInputProps>(
|
export const SearchInput = forwardRef<TextInput, SearchInputProps>(
|
||||||
function SearchInput({value, label, onClearText, ...rest}, ref) {
|
function SearchInput({value, label, onClearText, ...rest}, ref) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {_} = useLingui()
|
const {t: l} = useLingui()
|
||||||
const showClear = value && value.length > 0
|
const showClear = value && value.length > 0
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -31,9 +30,9 @@ export const SearchInput = React.forwardRef<TextInput, SearchInputProps>(
|
|||||||
<TextField.Icon icon={MagnifyingGlassIcon} />
|
<TextField.Icon icon={MagnifyingGlassIcon} />
|
||||||
<TextField.Input
|
<TextField.Input
|
||||||
inputRef={ref}
|
inputRef={ref}
|
||||||
label={label || _(msg`Search`)}
|
label={label || l`Search`}
|
||||||
value={value}
|
value={value}
|
||||||
placeholder={_(msg`Search`)}
|
placeholder={l`Search`}
|
||||||
returnKeyType="search"
|
returnKeyType="search"
|
||||||
keyboardAppearance={t.scheme}
|
keyboardAppearance={t.scheme}
|
||||||
selectTextOnFocus={IS_NATIVE}
|
selectTextOnFocus={IS_NATIVE}
|
||||||
@@ -67,7 +66,7 @@ export const SearchInput = React.forwardRef<TextInput, SearchInputProps>(
|
|||||||
<Button
|
<Button
|
||||||
testID="searchTextInputClearBtn"
|
testID="searchTextInputClearBtn"
|
||||||
onPress={onClearText}
|
onPress={onClearText}
|
||||||
label={_(msg`Clear search query`)}
|
label={l`Clear search query`}
|
||||||
hitSlop={HITSLOP_10}
|
hitSlop={HITSLOP_10}
|
||||||
size="tiny"
|
size="tiny"
|
||||||
shape="round"
|
shape="round"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {Trans, useLingui} from '@lingui/react/macro'
|
|||||||
|
|
||||||
import {urls} from '#/lib/constants'
|
import {urls} from '#/lib/constants'
|
||||||
import {usePostViewTracking} from '#/lib/hooks/usePostViewTracking'
|
import {usePostViewTracking} from '#/lib/hooks/usePostViewTracking'
|
||||||
|
import {useCallOnce} from '#/lib/once'
|
||||||
import {cleanError} from '#/lib/strings/errors'
|
import {cleanError} from '#/lib/strings/errors'
|
||||||
import {augmentSearchQuery} from '#/lib/strings/helpers'
|
import {augmentSearchQuery} from '#/lib/strings/helpers'
|
||||||
import {useActorSearch} from '#/state/queries/actor-search'
|
import {useActorSearch} from '#/state/queries/actor-search'
|
||||||
@@ -25,6 +26,7 @@ import {InlineLinkText} from '#/components/Link'
|
|||||||
import {ListFooter} from '#/components/Lists'
|
import {ListFooter} from '#/components/Lists'
|
||||||
import {SearchError} from '#/components/SearchError'
|
import {SearchError} from '#/components/SearchError'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
import {type Metrics, useAnalytics} from '#/analytics'
|
||||||
import type * as bsky from '#/types/bsky'
|
import type * as bsky from '#/types/bsky'
|
||||||
|
|
||||||
let SearchResults = ({
|
let SearchResults = ({
|
||||||
@@ -161,7 +163,12 @@ function EmptyState({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function NoResultsText({query}: {query: string}) {
|
function NoResultsText({
|
||||||
|
query,
|
||||||
|
}: {
|
||||||
|
sort?: 'top' | 'latest' | 'people' | 'feeds'
|
||||||
|
query: string
|
||||||
|
}) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {t: l} = useLingui()
|
const {t: l} = useLingui()
|
||||||
|
|
||||||
@@ -185,7 +192,7 @@ function NoResultsText({query}: {query: string}) {
|
|||||||
})}
|
})}
|
||||||
to={urls.website.blog.searchTipsAndTricks}
|
to={urls.website.blog.searchTipsAndTricks}
|
||||||
style={[a.text_md, a.leading_snug]}>
|
style={[a.text_md, a.leading_snug]}>
|
||||||
read about how to use search filters
|
read about how to use search filters.
|
||||||
</InlineLinkText>
|
</InlineLinkText>
|
||||||
.
|
.
|
||||||
</Trans>
|
</Trans>
|
||||||
@@ -214,6 +221,7 @@ let SearchScreenPostResults = ({
|
|||||||
sort?: 'top' | 'latest'
|
sort?: 'top' | 'latest'
|
||||||
active: boolean
|
active: boolean
|
||||||
}): React.ReactNode => {
|
}): React.ReactNode => {
|
||||||
|
const ax = useAnalytics()
|
||||||
const {t: l} = useLingui()
|
const {t: l} = useLingui()
|
||||||
const {currentAccount, hasSession} = useSession()
|
const {currentAccount, hasSession} = useSession()
|
||||||
const [isPTR, setIsPTR] = useState(false)
|
const [isPTR, setIsPTR] = useState(false)
|
||||||
@@ -277,6 +285,19 @@ let SearchScreenPostResults = ({
|
|||||||
const closeAllActiveElements = useCloseAllActiveElements()
|
const closeAllActiveElements = useCloseAllActiveElements()
|
||||||
const {requestSwitchToAccount} = useLoggedOutViewControls()
|
const {requestSwitchToAccount} = useLoggedOutViewControls()
|
||||||
|
|
||||||
|
const fireTracking = useCallOnce(() => {
|
||||||
|
if (sort) {
|
||||||
|
// ts only
|
||||||
|
ax.metric('search:results:loaded', {
|
||||||
|
tab: sort,
|
||||||
|
initialCount: items.length,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (isFetched && sort) {
|
||||||
|
fireTracking()
|
||||||
|
}
|
||||||
|
|
||||||
const showSignIn = () => {
|
const showSignIn = () => {
|
||||||
closeAllActiveElements()
|
closeAllActiveElements()
|
||||||
requestSwitchToAccount({requestedAccount: 'none'})
|
requestSwitchToAccount({requestedAccount: 'none'})
|
||||||
@@ -292,7 +313,7 @@ let SearchScreenPostResults = ({
|
|||||||
<SearchError title={l`Search is currently unavailable when logged out`}>
|
<SearchError title={l`Search is currently unavailable when logged out`}>
|
||||||
<Text style={[a.text_md, a.text_center, a.leading_snug]}>
|
<Text style={[a.text_md, a.text_center, a.leading_snug]}>
|
||||||
<Trans>
|
<Trans>
|
||||||
<InlineLinkText label={l`Sign in`} to={'#'} onPress={showSignIn}>
|
<InlineLinkText label={l`Sign in`} to="#" onPress={showSignIn}>
|
||||||
Sign in
|
Sign in
|
||||||
</InlineLinkText>
|
</InlineLinkText>
|
||||||
<Text style={t.atoms.text_contrast_medium}> or </Text>
|
<Text style={t.atoms.text_contrast_medium}> or </Text>
|
||||||
@@ -315,7 +336,7 @@ let SearchScreenPostResults = ({
|
|||||||
|
|
||||||
return error ? (
|
return error ? (
|
||||||
<EmptyState
|
<EmptyState
|
||||||
messageText={l`We're sorry, but your search could not be completed. Please try again in a few minutes.`}
|
messageText={l`We’re sorry, but your search could not be completed. Please try again in a few minutes.`}
|
||||||
error={cleanError(error)}
|
error={cleanError(error)}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
@@ -325,9 +346,17 @@ let SearchScreenPostResults = ({
|
|||||||
{posts.length ? (
|
{posts.length ? (
|
||||||
<List
|
<List
|
||||||
data={items}
|
data={items}
|
||||||
renderItem={({item}: {item: SearchResultSlice}) => {
|
renderItem={({
|
||||||
|
item,
|
||||||
|
index,
|
||||||
|
}: {
|
||||||
|
item: SearchResultSlice
|
||||||
|
index: number
|
||||||
|
}) => {
|
||||||
if (item.type === 'post') {
|
if (item.type === 'post') {
|
||||||
return <Post post={item.post} />
|
return (
|
||||||
|
<SearchPost from={sort} position={index} post={item.post} />
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -363,6 +392,29 @@ let SearchScreenPostResults = ({
|
|||||||
}
|
}
|
||||||
SearchScreenPostResults = memo(SearchScreenPostResults)
|
SearchScreenPostResults = memo(SearchScreenPostResults)
|
||||||
|
|
||||||
|
function SearchPost({
|
||||||
|
from,
|
||||||
|
position,
|
||||||
|
post,
|
||||||
|
}: {
|
||||||
|
from: Metrics['search:result:press']['tab']
|
||||||
|
position: Metrics['search:result:press']['position']
|
||||||
|
post: AppBskyFeedDefs.PostView
|
||||||
|
}) {
|
||||||
|
const ax = useAnalytics()
|
||||||
|
|
||||||
|
const onBeforePress = useCallback(() => {
|
||||||
|
ax.metric('search:result:press', {
|
||||||
|
tab: from,
|
||||||
|
resultType: 'post',
|
||||||
|
position,
|
||||||
|
uri: post.uri,
|
||||||
|
})
|
||||||
|
}, [ax, from, position, post])
|
||||||
|
|
||||||
|
return <Post post={post} onBeforePress={onBeforePress} />
|
||||||
|
}
|
||||||
|
|
||||||
let SearchScreenUserResults = ({
|
let SearchScreenUserResults = ({
|
||||||
query,
|
query,
|
||||||
active,
|
active,
|
||||||
@@ -370,6 +422,7 @@ let SearchScreenUserResults = ({
|
|||||||
query: string
|
query: string
|
||||||
active: boolean
|
active: boolean
|
||||||
}): React.ReactNode => {
|
}): React.ReactNode => {
|
||||||
|
const ax = useAnalytics()
|
||||||
const {t: l} = useLingui()
|
const {t: l} = useLingui()
|
||||||
const {hasSession} = useSession()
|
const {hasSession} = useSession()
|
||||||
const [isPTR, setIsPTR] = useState(false)
|
const [isPTR, setIsPTR] = useState(false)
|
||||||
@@ -403,6 +456,16 @@ let SearchScreenUserResults = ({
|
|||||||
return results?.pages.flatMap(page => page.actors) || []
|
return results?.pages.flatMap(page => page.actors) || []
|
||||||
}, [results])
|
}, [results])
|
||||||
|
|
||||||
|
const fireTracking = useCallOnce(() => {
|
||||||
|
ax.metric('search:results:loaded', {
|
||||||
|
tab: 'people',
|
||||||
|
initialCount: profiles.length,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
if (isFetched) {
|
||||||
|
fireTracking()
|
||||||
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
return (
|
return (
|
||||||
<EmptyState
|
<EmptyState
|
||||||
@@ -417,9 +480,13 @@ let SearchScreenUserResults = ({
|
|||||||
{profiles.length ? (
|
{profiles.length ? (
|
||||||
<List
|
<List
|
||||||
data={profiles}
|
data={profiles}
|
||||||
renderItem={({item}: {item: bsky.profile.AnyProfileView}) => (
|
renderItem={({
|
||||||
<ProfileCardWithFollowBtn profile={item} />
|
item,
|
||||||
)}
|
index,
|
||||||
|
}: {
|
||||||
|
item: bsky.profile.AnyProfileView
|
||||||
|
index: number
|
||||||
|
}) => <SearchScreenProfileButton position={index} profile={item} />}
|
||||||
keyExtractor={(item: bsky.profile.AnyProfileView) => item.did}
|
keyExtractor={(item: bsky.profile.AnyProfileView) => item.did}
|
||||||
refreshing={isPTR}
|
refreshing={isPTR}
|
||||||
onRefresh={() => void onPullToRefresh()}
|
onRefresh={() => void onPullToRefresh()}
|
||||||
@@ -442,6 +509,26 @@ let SearchScreenUserResults = ({
|
|||||||
}
|
}
|
||||||
SearchScreenUserResults = memo(SearchScreenUserResults)
|
SearchScreenUserResults = memo(SearchScreenUserResults)
|
||||||
|
|
||||||
|
function SearchScreenProfileButton({
|
||||||
|
position,
|
||||||
|
profile,
|
||||||
|
}: {
|
||||||
|
position: number
|
||||||
|
profile: bsky.profile.AnyProfileView
|
||||||
|
}) {
|
||||||
|
const ax = useAnalytics()
|
||||||
|
|
||||||
|
const handlePress = () => {
|
||||||
|
ax.metric('search:result:press', {
|
||||||
|
tab: 'people',
|
||||||
|
resultType: 'profile',
|
||||||
|
position,
|
||||||
|
uri: profile.did,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return <ProfileCardWithFollowBtn profile={profile} onPress={handlePress} />
|
||||||
|
}
|
||||||
|
|
||||||
let SearchScreenFeedsResults = ({
|
let SearchScreenFeedsResults = ({
|
||||||
query,
|
query,
|
||||||
active,
|
active,
|
||||||
@@ -449,6 +536,7 @@ let SearchScreenFeedsResults = ({
|
|||||||
query: string
|
query: string
|
||||||
active: boolean
|
active: boolean
|
||||||
}): React.ReactNode => {
|
}): React.ReactNode => {
|
||||||
|
const ax = useAnalytics()
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
|
|
||||||
const {data: results, isFetched} = usePopularFeedsSearch({
|
const {data: results, isFetched} = usePopularFeedsSearch({
|
||||||
@@ -456,12 +544,28 @@ let SearchScreenFeedsResults = ({
|
|||||||
enabled: active,
|
enabled: active,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const fireTracking = useCallOnce(() => {
|
||||||
|
ax.metric('search:results:loaded', {
|
||||||
|
tab: 'feeds',
|
||||||
|
initialCount: results?.length ?? 0,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
if (isFetched) {
|
||||||
|
fireTracking()
|
||||||
|
}
|
||||||
|
|
||||||
return isFetched && results ? (
|
return isFetched && results ? (
|
||||||
<>
|
<>
|
||||||
{results.length ? (
|
{results.length ? (
|
||||||
<List
|
<List
|
||||||
data={results}
|
data={results}
|
||||||
renderItem={({item}: {item: AppBskyFeedDefs.GeneratorView}) => (
|
renderItem={({
|
||||||
|
item,
|
||||||
|
index,
|
||||||
|
}: {
|
||||||
|
item: AppBskyFeedDefs.GeneratorView
|
||||||
|
index: number
|
||||||
|
}) => (
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
a.border_t,
|
a.border_t,
|
||||||
@@ -469,7 +573,7 @@ let SearchScreenFeedsResults = ({
|
|||||||
a.px_lg,
|
a.px_lg,
|
||||||
a.py_lg,
|
a.py_lg,
|
||||||
]}>
|
]}>
|
||||||
<FeedCard.Default view={item} />
|
<SearchFeedCard position={index} view={item} />
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
keyExtractor={(item: AppBskyFeedDefs.GeneratorView) => item.uri}
|
keyExtractor={(item: AppBskyFeedDefs.GeneratorView) => item.uri}
|
||||||
@@ -485,3 +589,24 @@ let SearchScreenFeedsResults = ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
SearchScreenFeedsResults = memo(SearchScreenFeedsResults)
|
SearchScreenFeedsResults = memo(SearchScreenFeedsResults)
|
||||||
|
|
||||||
|
function SearchFeedCard({
|
||||||
|
position,
|
||||||
|
view,
|
||||||
|
}: {
|
||||||
|
position: number
|
||||||
|
view: AppBskyFeedDefs.GeneratorView
|
||||||
|
}) {
|
||||||
|
const ax = useAnalytics()
|
||||||
|
|
||||||
|
const handleOnPress = () => {
|
||||||
|
ax.metric('search:result:press', {
|
||||||
|
tab: 'feeds',
|
||||||
|
resultType: 'feed',
|
||||||
|
position,
|
||||||
|
uri: view.uri,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return <FeedCard.Default view={view} onPress={handleOnPress} />
|
||||||
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import {Button, ButtonText} from '#/components/Button'
|
|||||||
import {SearchInput} from '#/components/forms/SearchInput'
|
import {SearchInput} from '#/components/forms/SearchInput'
|
||||||
import * as Layout from '#/components/Layout'
|
import * as Layout from '#/components/Layout'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
import {useAnalytics} from '#/analytics'
|
||||||
import {IS_WEB} from '#/env'
|
import {IS_WEB} from '#/env'
|
||||||
import {account, useStorage} from '#/storage'
|
import {account, useStorage} from '#/storage'
|
||||||
import type * as bsky from '#/types/bsky'
|
import type * as bsky from '#/types/bsky'
|
||||||
@@ -79,6 +80,7 @@ export function SearchScreenShell({
|
|||||||
inputPlaceholder?: string
|
inputPlaceholder?: string
|
||||||
isExplore?: boolean
|
isExplore?: boolean
|
||||||
}) {
|
}) {
|
||||||
|
const ax = useAnalytics()
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {gtMobile} = useBreakpoints()
|
const {gtMobile} = useBreakpoints()
|
||||||
const navigation = useNavigation<NavigationProp>()
|
const navigation = useNavigation<NavigationProp>()
|
||||||
@@ -225,9 +227,15 @@ export function SearchScreenShell({
|
|||||||
}
|
}
|
||||||
}, [setShowAutocomplete, setSearchText, navigation, route.params, route.name])
|
}, [setShowAutocomplete, setSearchText, navigation, route.params, route.name])
|
||||||
|
|
||||||
const onSubmit = useCallback(() => {
|
const onSubmit = useCallback(
|
||||||
navigateToItem(searchText)
|
(source: 'typed' | 'autocomplete') => () => {
|
||||||
}, [navigateToItem, searchText])
|
ax.metric('search:query', {
|
||||||
|
source,
|
||||||
|
})
|
||||||
|
navigateToItem(searchText)
|
||||||
|
},
|
||||||
|
[ax, navigateToItem, searchText],
|
||||||
|
)
|
||||||
|
|
||||||
const onAutocompleteResultPress = useCallback(() => {
|
const onAutocompleteResultPress = useCallback(() => {
|
||||||
if (IS_WEB) {
|
if (IS_WEB) {
|
||||||
@@ -367,7 +375,7 @@ export function SearchScreenShell({
|
|||||||
onFocus={onSearchInputFocus}
|
onFocus={onSearchInputFocus}
|
||||||
onChangeText={onChangeText}
|
onChangeText={onChangeText}
|
||||||
onClearText={onPressClearQuery}
|
onClearText={onPressClearQuery}
|
||||||
onSubmitEditing={onSubmit}
|
onSubmitEditing={onSubmit('typed')}
|
||||||
placeholder={
|
placeholder={
|
||||||
inputPlaceholder ?? l`Search for posts, users, or feeds`
|
inputPlaceholder ?? l`Search for posts, users, or feeds`
|
||||||
}
|
}
|
||||||
@@ -420,7 +428,7 @@ export function SearchScreenShell({
|
|||||||
isAutocompleteFetching={isAutocompleteFetching}
|
isAutocompleteFetching={isAutocompleteFetching}
|
||||||
autocompleteData={autocompleteData}
|
autocompleteData={autocompleteData}
|
||||||
searchText={searchText}
|
searchText={searchText}
|
||||||
onSubmit={onSubmit}
|
onSubmit={onSubmit('autocomplete')}
|
||||||
onResultPress={onAutocompleteResultPress}
|
onResultPress={onAutocompleteResultPress}
|
||||||
onProfileClick={handleProfileClick}
|
onProfileClick={handleProfileClick}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {SearchLinkCard} from '#/view/shell/desktop/Search'
|
|||||||
import {SearchProfileCard} from '#/screens/Search/components/SearchProfileCard'
|
import {SearchProfileCard} from '#/screens/Search/components/SearchProfileCard'
|
||||||
import {atoms as a, native} from '#/alf'
|
import {atoms as a, native} from '#/alf'
|
||||||
import * as Layout from '#/components/Layout'
|
import * as Layout from '#/components/Layout'
|
||||||
|
import {useAnalytics} from '#/analytics'
|
||||||
import {IS_NATIVE} from '#/env'
|
import {IS_NATIVE} from '#/env'
|
||||||
|
|
||||||
let AutocompleteResults = ({
|
let AutocompleteResults = ({
|
||||||
@@ -26,6 +27,7 @@ let AutocompleteResults = ({
|
|||||||
onResultPress: () => void
|
onResultPress: () => void
|
||||||
onProfileClick: (profile: AppBskyActorDefs.ProfileViewBasic) => void
|
onProfileClick: (profile: AppBskyActorDefs.ProfileViewBasic) => void
|
||||||
}): React.ReactNode => {
|
}): React.ReactNode => {
|
||||||
|
const ax = useAnalytics()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
return (
|
return (
|
||||||
@@ -51,12 +53,16 @@ let AutocompleteResults = ({
|
|||||||
}
|
}
|
||||||
style={a.border_b}
|
style={a.border_b}
|
||||||
/>
|
/>
|
||||||
{autocompleteData?.map(item => (
|
{autocompleteData?.map((item, index) => (
|
||||||
<SearchProfileCard
|
<SearchProfileCard
|
||||||
key={item.did}
|
key={item.did}
|
||||||
profile={item}
|
profile={item}
|
||||||
moderationOpts={moderationOpts}
|
moderationOpts={moderationOpts}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
|
ax.metric('search:autocomplete:press', {
|
||||||
|
profileDid: item.did,
|
||||||
|
position: index,
|
||||||
|
})
|
||||||
onProfileClick(item)
|
onProfileClick(item)
|
||||||
onResultPress()
|
onResultPress()
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import {Pressable, ScrollView, View} from 'react-native'
|
import {Pressable, ScrollView, View} from 'react-native'
|
||||||
import {moderateProfile, type ModerationOpts} from '@atproto/api'
|
import {moderateProfile, type ModerationOpts} from '@atproto/api'
|
||||||
import {msg} from '@lingui/core/macro'
|
import {Trans, useLingui} from '@lingui/react/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
|
||||||
import {Trans} from '@lingui/react/macro'
|
|
||||||
|
|
||||||
import {createHitslop, HITSLOP_10} from '#/lib/constants'
|
import {createHitslop, HITSLOP_10} from '#/lib/constants'
|
||||||
import {makeProfileLink} from '#/lib/routes/links'
|
import {makeProfileLink} from '#/lib/routes/links'
|
||||||
@@ -19,6 +17,7 @@ import {Link} from '#/components/Link'
|
|||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {useSimpleVerificationState} from '#/components/verification'
|
import {useSimpleVerificationState} from '#/components/verification'
|
||||||
import {VerificationCheck} from '#/components/verification/VerificationCheck'
|
import {VerificationCheck} from '#/components/verification/VerificationCheck'
|
||||||
|
import {useAnalytics} from '#/analytics'
|
||||||
import type * as bsky from '#/types/bsky'
|
import type * as bsky from '#/types/bsky'
|
||||||
|
|
||||||
export function SearchHistory({
|
export function SearchHistory({
|
||||||
@@ -36,7 +35,8 @@ export function SearchHistory({
|
|||||||
onRemoveItemClick: (item: string) => void
|
onRemoveItemClick: (item: string) => void
|
||||||
onRemoveProfileClick: (profile: bsky.profile.AnyProfileView) => void
|
onRemoveProfileClick: (profile: bsky.profile.AnyProfileView) => void
|
||||||
}) {
|
}) {
|
||||||
const {_} = useLingui()
|
const ax = useAnalytics()
|
||||||
|
const {t: l} = useLingui()
|
||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -47,7 +47,7 @@ export function SearchHistory({
|
|||||||
{(searchHistory.length > 0 || selectedProfiles.length > 0) && (
|
{(searchHistory.length > 0 || selectedProfiles.length > 0) && (
|
||||||
<View style={[a.px_lg, a.pt_sm]}>
|
<View style={[a.px_lg, a.pt_sm]}>
|
||||||
<Text style={[a.text_md, a.font_semi_bold]}>
|
<Text style={[a.text_md, a.font_semi_bold]}>
|
||||||
<Trans>Recent Searches</Trans>
|
<Trans>Recent searches</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
@@ -66,12 +66,18 @@ export function SearchHistory({
|
|||||||
a.gap_xl,
|
a.gap_xl,
|
||||||
]}>
|
]}>
|
||||||
{moderationOpts &&
|
{moderationOpts &&
|
||||||
selectedProfiles.map(profile => (
|
selectedProfiles.map((profile, index) => (
|
||||||
<RecentProfileItem
|
<RecentProfileItem
|
||||||
key={profile.did}
|
key={profile.did}
|
||||||
profile={profile}
|
profile={profile}
|
||||||
moderationOpts={moderationOpts}
|
moderationOpts={moderationOpts}
|
||||||
onPress={() => onProfileClick(profile)}
|
onPress={() => {
|
||||||
|
ax.metric('search:recent:press', {
|
||||||
|
profileDid: profile.did,
|
||||||
|
position: index,
|
||||||
|
})
|
||||||
|
onProfileClick(profile)
|
||||||
|
}}
|
||||||
onRemove={() => onRemoveProfileClick(profile)}
|
onRemove={() => onRemoveProfileClick(profile)}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
@@ -86,13 +92,18 @@ export function SearchHistory({
|
|||||||
<View key={index} style={[a.flex_row, a.align_center]}>
|
<View key={index} style={[a.flex_row, a.align_center]}>
|
||||||
<Pressable
|
<Pressable
|
||||||
accessibilityRole="button"
|
accessibilityRole="button"
|
||||||
onPress={() => onItemClick(historyItem)}
|
onPress={() => {
|
||||||
|
ax.metric('search:query', {
|
||||||
|
source: 'history',
|
||||||
|
})
|
||||||
|
onItemClick(historyItem)
|
||||||
|
}}
|
||||||
hitSlop={HITSLOP_10}
|
hitSlop={HITSLOP_10}
|
||||||
style={[a.flex_1, a.py_sm]}>
|
style={[a.flex_1, a.py_sm]}>
|
||||||
<Text style={[a.text_md]}>{historyItem}</Text>
|
<Text style={[a.text_md]}>{historyItem}</Text>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
<Button
|
<Button
|
||||||
label={_(msg`Remove ${historyItem}`)}
|
label={l`Remove ${historyItem}`}
|
||||||
onPress={() => onRemoveItemClick(historyItem)}
|
onPress={() => onRemoveItemClick(historyItem)}
|
||||||
size="small"
|
size="small"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
@@ -120,7 +131,7 @@ function RecentProfileItem({
|
|||||||
onPress: () => void
|
onPress: () => void
|
||||||
onRemove: () => void
|
onRemove: () => void
|
||||||
}) {
|
}) {
|
||||||
const {_} = useLingui()
|
const {t: l} = useLingui()
|
||||||
const width = 80
|
const width = 80
|
||||||
|
|
||||||
const moderation = moderateProfile(profile, moderationOpts)
|
const moderation = moderateProfile(profile, moderationOpts)
|
||||||
@@ -165,7 +176,7 @@ function RecentProfileItem({
|
|||||||
</View>
|
</View>
|
||||||
</Link>
|
</Link>
|
||||||
<Button
|
<Button
|
||||||
label={_(msg`Remove profile`)}
|
label={l`Remove profile`}
|
||||||
hitSlop={createHitslop(6)}
|
hitSlop={createHitslop(6)}
|
||||||
size="tiny"
|
size="tiny"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {View} from 'react-native'
|
import {type GestureResponderEvent, View} from 'react-native'
|
||||||
|
|
||||||
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
@@ -11,12 +11,14 @@ export function ProfileCardWithFollowBtn({
|
|||||||
logContext = 'ProfileCard',
|
logContext = 'ProfileCard',
|
||||||
position,
|
position,
|
||||||
contextProfileDid,
|
contextProfileDid,
|
||||||
|
onPress,
|
||||||
}: {
|
}: {
|
||||||
profile: bsky.profile.AnyProfileView
|
profile: bsky.profile.AnyProfileView
|
||||||
noBorder?: boolean
|
noBorder?: boolean
|
||||||
logContext?: 'ProfileCard' | 'StarterPackProfilesList'
|
logContext?: 'ProfileCard' | 'StarterPackProfilesList'
|
||||||
position?: number
|
position?: number
|
||||||
contextProfileDid?: string
|
contextProfileDid?: string
|
||||||
|
onPress?: (e: GestureResponderEvent) => void
|
||||||
}) {
|
}) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
@@ -36,6 +38,7 @@ export function ProfileCardWithFollowBtn({
|
|||||||
logContext={logContext}
|
logContext={logContext}
|
||||||
position={position}
|
position={position}
|
||||||
contextProfileDid={contextProfileDid}
|
contextProfileDid={contextProfileDid}
|
||||||
|
onPress={onPress}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react'
|
import {memo, useCallback, useState} from 'react'
|
||||||
import {
|
import {
|
||||||
ActivityIndicator,
|
ActivityIndicator,
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
@@ -6,8 +6,7 @@ import {
|
|||||||
View,
|
View,
|
||||||
type ViewStyle,
|
type ViewStyle,
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import {msg} from '@lingui/core/macro'
|
import {useLingui} from '@lingui/react/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
|
||||||
import {StackActions, useNavigation} from '@react-navigation/native'
|
import {StackActions, useNavigation} from '@react-navigation/native'
|
||||||
|
|
||||||
import {usePalette} from '#/lib/hooks/usePalette'
|
import {usePalette} from '#/lib/hooks/usePalette'
|
||||||
@@ -68,15 +67,15 @@ let SearchLinkCard = ({
|
|||||||
</Link>
|
</Link>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
SearchLinkCard = React.memo(SearchLinkCard)
|
SearchLinkCard = memo(SearchLinkCard)
|
||||||
export {SearchLinkCard}
|
export {SearchLinkCard}
|
||||||
|
|
||||||
export function DesktopSearch() {
|
export function DesktopSearch() {
|
||||||
const {_} = useLingui()
|
const {t: l} = useLingui()
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const navigation = useNavigation<NavigationProp>()
|
const navigation = useNavigation<NavigationProp>()
|
||||||
const [isActive, setIsActive] = React.useState<boolean>(false)
|
const [isActive, setIsActive] = useState<boolean>(false)
|
||||||
const [query, setQuery] = React.useState<string>('')
|
const [query, setQuery] = useState<string>('')
|
||||||
const {data: autocompleteData, isFetching} = useActorAutocompleteQuery(
|
const {data: autocompleteData, isFetching} = useActorAutocompleteQuery(
|
||||||
query,
|
query,
|
||||||
true,
|
true,
|
||||||
@@ -84,23 +83,23 @@ export function DesktopSearch() {
|
|||||||
|
|
||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
|
|
||||||
const onChangeText = React.useCallback((text: string) => {
|
const onChangeText = useCallback((text: string) => {
|
||||||
setQuery(text)
|
setQuery(text)
|
||||||
setIsActive(text.length > 0)
|
setIsActive(text.length > 0)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const onPressCancelSearch = React.useCallback(() => {
|
const onPressCancelSearch = useCallback(() => {
|
||||||
setQuery('')
|
setQuery('')
|
||||||
setIsActive(false)
|
setIsActive(false)
|
||||||
}, [setQuery])
|
}, [setQuery])
|
||||||
|
|
||||||
const onSubmit = React.useCallback(() => {
|
const onSubmit = useCallback(() => {
|
||||||
setIsActive(false)
|
setIsActive(false)
|
||||||
if (!query.length) return
|
if (!query.length) return
|
||||||
navigation.dispatch(StackActions.push('Search', {q: query}))
|
navigation.dispatch(StackActions.push('Search', {q: query}))
|
||||||
}, [query, navigation])
|
}, [query, navigation])
|
||||||
|
|
||||||
const onSearchProfileCardPress = React.useCallback(() => {
|
const onSearchProfileCardPress = useCallback(() => {
|
||||||
setQuery('')
|
setQuery('')
|
||||||
setIsActive(false)
|
setIsActive(false)
|
||||||
}, [])
|
}, [])
|
||||||
@@ -128,7 +127,7 @@ export function DesktopSearch() {
|
|||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<SearchLinkCard
|
<SearchLinkCard
|
||||||
label={_(msg`Search for "${query}"`)}
|
label={l`Search for "${query}"`}
|
||||||
to={`/search?q=${encodeURIComponent(query)}`}
|
to={`/search?q=${encodeURIComponent(query)}`}
|
||||||
style={
|
style={
|
||||||
(autocompleteData?.length ?? 0) > 0
|
(autocompleteData?.length ?? 0) > 0
|
||||||
|
|||||||
Reference in New Issue
Block a user