about summary refs log tree commit diff
path: root/src/components/dms/MessageProfileButton.tsx
blob: 6f227de65a22487e525e13b92e38f09abf1336f1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import React from 'react'
import {AppBskyActorDefs} from '@atproto/api'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'

import {useMaybeConvoForUser} from '#/state/queries/messages/get-convo-for-members'
import {atoms as a, useTheme} from '#/alf'
import {Message_Stroke2_Corner0_Rounded as Message} from '../icons/Message'
import {Link} from '../Link'

export function MessageProfileButton({
  profile,
}: {
  profile: AppBskyActorDefs.ProfileView
}) {
  const {_} = useLingui()
  const t = useTheme()

  const {data: convoId} = useMaybeConvoForUser(profile.did)

  if (!convoId) return null

  return (
    <Link
      testID="dmBtn"
      size="small"
      color="secondary"
      variant="solid"
      shape="round"
      label={_(msg`Message ${profile.handle}`)}
      to={`/messages/${convoId}`}
      style={[a.justify_center, {width: 36, height: 36}]}>
      <Message
        style={[t.atoms.text, {marginLeft: 1, marginBottom: 1}]}
        size="md"
      />
    </Link>
  )
}