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

49 lines
1.4 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'
import { relationshipFetch } from '@utils/fetches/relationshipFetch'
import { StyleConstants } from '@utils/styles/constants'
import React from 'react'
2020-12-27 16:25:29 +01:00
import { StyleSheet, View } from 'react-native'
import { useQuery } from 'react-query'
2020-12-27 16:25:29 +01:00
export interface Props {
account: Mastodon.Account | undefined
}
const AccountInformationActions: React.FC<Props> = ({ account }) => {
const navigation = useNavigation()
const relationshipQueryKey = ['Relationship', { id: account?.id }]
2021-01-01 17:52:14 +01:00
const query = useQuery(relationshipQueryKey, relationshipFetch)
2020-12-27 16:25:29 +01:00
return (
<View style={styles.actions}>
{query.data && !query.data.blocked_by ? (
2020-12-27 16:25:29 +01:00
<Button
round
2020-12-27 16:25:29 +01:00
type='icon'
content='Mail'
style={styles.actionConversation}
2020-12-27 16:25:29 +01:00
onPress={() =>
2020-12-29 16:19:04 +01:00
navigation.navigate('Screen-Shared-Compose', {
type: 'conversation',
incomingStatus: { account }
2020-12-27 16:25:29 +01:00
})
}
/>
) : null}
{account && account.id && <RelationshipOutgoing id={account.id} />}
2020-12-27 16:25:29 +01:00
</View>
)
}
const styles = StyleSheet.create({
actions: {
alignSelf: 'flex-end',
flexDirection: 'row'
},
actionConversation: { marginRight: StyleConstants.Spacing.S }
2020-12-27 16:25:29 +01:00
})
export default AccountInformationActions