2021-01-04 10:50:24 +01:00
|
|
|
import Button from '@components/Button'
|
2022-12-04 13:26:36 +01:00
|
|
|
import menuAt from '@components/contextMenu/at'
|
2021-01-04 10:50:24 +01:00
|
|
|
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'
|
2022-12-28 23:41:36 +01:00
|
|
|
import { useAccountStorage } from '@utils/storage/actions'
|
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-05-09 21:59:03 +02:00
|
|
|
import { StyleSheet, View } from 'react-native'
|
2022-12-04 13:26:36 +01:00
|
|
|
import * as DropdownMenu from 'zeego/dropdown-menu'
|
2020-12-27 16:25:29 +01:00
|
|
|
|
|
|
|
export interface Props {
|
|
|
|
account: Mastodon.Account | undefined
|
2021-05-09 21:59:03 +02:00
|
|
|
myInfo?: boolean
|
2021-01-23 02:41:50 +01:00
|
|
|
}
|
|
|
|
|
2021-05-09 21:59:03 +02:00
|
|
|
const AccountInformationActions: React.FC<Props> = ({ account, myInfo }) => {
|
2022-11-06 23:39:31 +01:00
|
|
|
if (!account || account.suspended) {
|
2021-07-07 17:19:13 +02:00
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
2021-05-09 21:59:03 +02:00
|
|
|
const { t } = useTranslation('screenTabs')
|
2021-08-29 15:25:38 +02:00
|
|
|
const navigation = useNavigation<any>()
|
2021-05-09 21:59:03 +02:00
|
|
|
|
|
|
|
if (account?.moved) {
|
|
|
|
const accountMoved = account.moved
|
|
|
|
return (
|
|
|
|
<View style={styles.base}>
|
|
|
|
<Button
|
|
|
|
type='text'
|
|
|
|
content={t('shared.account.moved')}
|
2022-11-29 23:44:11 +01:00
|
|
|
onPress={() => navigation.push('Tab-Shared-Account', { account: accountMoved })}
|
2021-05-09 21:59:03 +02:00
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (myInfo) {
|
|
|
|
return (
|
|
|
|
<View style={styles.base}>
|
|
|
|
<Button
|
|
|
|
type='text'
|
|
|
|
disabled={account === undefined}
|
|
|
|
content={t('me.stacks.profile.name')}
|
|
|
|
onPress={() => navigation.navigate('Tab-Me-Profile')}
|
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-12-28 23:41:36 +01:00
|
|
|
const [accountId] = useAccountStorage.string('auth.account.id')
|
|
|
|
const ownAccount = account?.id === accountId
|
2021-05-09 21:59:03 +02:00
|
|
|
|
2022-12-04 13:26:36 +01:00
|
|
|
const query = useRelationshipQuery({ id: account.id })
|
|
|
|
const mAt = menuAt({ account })
|
|
|
|
|
2021-05-09 21:59:03 +02:00
|
|
|
if (!ownAccount && account) {
|
|
|
|
return (
|
|
|
|
<View style={styles.base}>
|
2022-12-04 13:26:36 +01:00
|
|
|
{query.data && !query.data.blocked_by ? (
|
|
|
|
<DropdownMenu.Root>
|
|
|
|
<DropdownMenu.Trigger>
|
|
|
|
<Button
|
|
|
|
round
|
|
|
|
type='icon'
|
|
|
|
content='AtSign'
|
|
|
|
style={{ marginRight: StyleConstants.Spacing.S }}
|
|
|
|
onPress={() => {}}
|
|
|
|
/>
|
|
|
|
</DropdownMenu.Trigger>
|
|
|
|
|
|
|
|
<DropdownMenu.Content>
|
|
|
|
{mAt.map((mGroup, index) => (
|
|
|
|
<DropdownMenu.Group key={index}>
|
|
|
|
{mGroup.map(menu => (
|
|
|
|
<DropdownMenu.Item key={menu.key} {...menu.item}>
|
|
|
|
<DropdownMenu.ItemTitle children={menu.title} />
|
|
|
|
<DropdownMenu.ItemIcon iosIconName={menu.icon} />
|
|
|
|
</DropdownMenu.Item>
|
|
|
|
))}
|
|
|
|
</DropdownMenu.Group>
|
|
|
|
))}
|
|
|
|
</DropdownMenu.Content>
|
|
|
|
</DropdownMenu.Root>
|
|
|
|
) : null}
|
2021-01-23 02:41:50 +01:00
|
|
|
<RelationshipOutgoing id={account.id} />
|
2021-05-09 21:59:03 +02:00
|
|
|
</View>
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
return null
|
|
|
|
}
|
2020-12-27 16:25:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
2021-05-09 21:59:03 +02:00
|
|
|
base: {
|
|
|
|
alignSelf: 'flex-end',
|
2022-12-04 13:26:36 +01:00
|
|
|
flexDirection: 'row',
|
|
|
|
alignItems: 'center'
|
|
|
|
}
|
2020-12-27 16:25:29 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
export default AccountInformationActions
|