2021-01-04 10:50:24 +01:00
|
|
|
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'
|
2021-01-04 10:50:24 +01:00
|
|
|
import { StyleConstants } from '@utils/styles/constants'
|
|
|
|
import React from 'react'
|
2021-01-23 02:41:50 +01:00
|
|
|
import { useTranslation } from 'react-i18next'
|
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-23 02:41:50 +01:00
|
|
|
const GoToMoved = ({ account }: { account: Mastodon.Account }) => {
|
|
|
|
const { t } = useTranslation('sharedAccount')
|
|
|
|
const navigation = useNavigation()
|
|
|
|
const query = useRelationshipQuery({ id: account.id })
|
|
|
|
|
|
|
|
return query.data && !query.data.blocked_by ? (
|
|
|
|
<Button
|
|
|
|
type='text'
|
|
|
|
content={t('content.moved')}
|
|
|
|
onPress={() =>
|
|
|
|
navigation.push('Screen-Shared-Account', { account: account.moved })
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
) : null
|
|
|
|
}
|
|
|
|
|
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 ? (
|
2021-01-23 02:41:50 +01:00
|
|
|
account.moved ? (
|
|
|
|
<GoToMoved account={account} />
|
|
|
|
) : (
|
|
|
|
<>
|
|
|
|
<Conversation account={account} />
|
|
|
|
<RelationshipOutgoing id={account.id} />
|
|
|
|
</>
|
|
|
|
)
|
2021-01-07 19:13:09 +01:00
|
|
|
) : null
|
2020-12-27 16:25:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
2021-01-04 10:50:24 +01:00
|
|
|
actionConversation: { marginRight: StyleConstants.Spacing.S }
|
2020-12-27 16:25:29 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
export default AccountInformationActions
|