tooot/src/screens/Shared/Account/Information/Actions.tsx

47 lines
1.3 KiB
TypeScript
Raw Normal View History

import Button from '@components/Button'
import { RelationshipOutgoing } from '@components/Relationship'
2020-12-27 16:25:29 +01:00
import { useNavigation } from '@react-navigation/native'
2021-01-11 21:36:57 +01:00
import { useRelationshipQuery } from '@utils/queryHooks/relationship'
import { StyleConstants } from '@utils/styles/constants'
import React from 'react'
2021-01-07 19:13:09 +01:00
import { StyleSheet } from 'react-native'
2020-12-27 16:25:29 +01:00
export interface Props {
account: Mastodon.Account | undefined
}
2021-01-07 19:13:09 +01:00
const Conversation = ({ account }: { account: Mastodon.Account }) => {
2020-12-27 16:25:29 +01:00
const navigation = useNavigation()
2021-01-11 21:36:57 +01:00
const query = useRelationshipQuery({ id: account.id })
2021-01-07 19:13:09 +01:00
return query.data && !query.data.blocked_by ? (
<Button
round
type='icon'
content='Mail'
style={styles.actionConversation}
onPress={() =>
navigation.navigate('Screen-Shared-Compose', {
type: 'conversation',
incomingStatus: { account }
})
}
/>
) : null
}
2020-12-27 16:25:29 +01:00
2021-01-07 19:13:09 +01:00
const AccountInformationActions: React.FC<Props> = ({ account }) => {
return account && account.id ? (
<>
<Conversation account={account} />
<RelationshipOutgoing id={account.id} />
</>
) : null
2020-12-27 16:25:29 +01:00
}
const styles = StyleSheet.create({
actionConversation: { marginRight: StyleConstants.Spacing.S }
2020-12-27 16:25:29 +01:00
})
export default AccountInformationActions