migrate the notification say-hello action to the chat client

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Samuel Newman
2026-08-03 19:38:24 +03:00
parent 0bf2ada0c6
commit 8f6181495e
@@ -21,12 +21,13 @@ import {
type ModerationOpts, type ModerationOpts,
} from '@atproto/api' } from '@atproto/api'
import {TID} from '@atproto/common-web' import {TID} from '@atproto/common-web'
import {type DidString} from '@atproto/syntax'
import {plural} from '@lingui/core/macro' import {plural} from '@lingui/core/macro'
import {Plural, Trans, useLingui} from '@lingui/react/macro' import {Plural, Trans, useLingui} from '@lingui/react/macro'
import {useNavigation} from '@react-navigation/native' import {useNavigation} from '@react-navigation/native'
import {useQueryClient} from '@tanstack/react-query' import {useQueryClient} from '@tanstack/react-query'
import {DM_SERVICE_HEADERS, MAX_POST_LINES} from '#/lib/constants' import {MAX_POST_LINES} from '#/lib/constants'
import {useAnimatedValue} from '#/lib/hooks/useAnimatedValue' import {useAnimatedValue} from '#/lib/hooks/useAnimatedValue'
import {makeProfileLink} from '#/lib/routes/links' import {makeProfileLink} from '#/lib/routes/links'
import {type NavigationProp} from '#/lib/routes/types' import {type NavigationProp} from '#/lib/routes/types'
@@ -38,7 +39,7 @@ import {useProfileShadow} from '#/state/cache/profile-shadow'
import {type FeedNotification} from '#/state/queries/notifications/feed' import {type FeedNotification} from '#/state/queries/notifications/feed'
import {useProfileFollowMutationQueue} from '#/state/queries/profile' import {useProfileFollowMutationQueue} from '#/state/queries/profile'
import {unstableCacheProfileView} from '#/state/queries/unstable-profile-cache' import {unstableCacheProfileView} from '#/state/queries/unstable-profile-cache'
import {useAgent, useSession} from '#/state/session' import {useChatClient, useSession} from '#/state/session'
import {FeedSourceCard} from '#/view/com/feeds/FeedSourceCard' import {FeedSourceCard} from '#/view/com/feeds/FeedSourceCard'
import {Post} from '#/view/com/post/Post' import {Post} from '#/view/com/post/Post'
import {formatCount} from '#/view/com/util/numeric/format' import {formatCount} from '#/view/com/util/numeric/format'
@@ -73,6 +74,7 @@ import * as Toast from '#/components/Toast'
import {Text} from '#/components/Typography' import {Text} from '#/components/Typography'
import {useAnalytics} from '#/analytics' import {useAnalytics} from '#/analytics'
import {IS_WEB} from '#/env' import {IS_WEB} from '#/env'
import {chat} from '#/lexicons'
import * as bsky from '#/types/bsky' import * as bsky from '#/types/bsky'
const MAX_AUTHORS = 5 const MAX_AUTHORS = 5
@@ -911,21 +913,21 @@ function FollowBackButton({profile}: {profile: AppBskyActorDefs.ProfileView}) {
function SayHelloBtn({profile}: {profile: AppBskyActorDefs.ProfileView}) { function SayHelloBtn({profile}: {profile: AppBskyActorDefs.ProfileView}) {
const {t: l} = useLingui() const {t: l} = useLingui()
const agent = useAgent() const client = useChatClient()
const {currentAccount} = useSession()
const navigation = useNavigation<NavigationProp>() const navigation = useNavigation<NavigationProp>()
const [isLoading, setIsLoading] = useState(false) const [isLoading, setIsLoading] = useState(false)
const onPress = async () => { const onPress = async () => {
try { try {
setIsLoading(true) setIsLoading(true)
const res = await agent.api.chat.bsky.convo.getConvoForMembers( const data = await client.call(chat.bsky.convo.getConvoForMembers, {
{ // both dids are already resolved - one from the profile view, one from
members: [profile.did, agent.session!.did], // the active session
}, members: [profile.did, currentAccount!.did] as DidString[],
{headers: DM_SERVICE_HEADERS}, })
)
navigation.navigate('MessagesConversation', { navigation.navigate('MessagesConversation', {
conversation: res.data.convo.id, conversation: data.convo.id,
}) })
} catch (e) { } catch (e) {
logger.error('Failed to get conversation', {safeMessage: e}) logger.error('Failed to get conversation', {safeMessage: e})