2021-01-03 02:00:26 +01:00
|
|
|
import Icon from '@components/Icon'
|
2022-05-07 00:52:32 +02:00
|
|
|
import CustomText from '@components/Text'
|
2022-05-08 00:24:15 +02:00
|
|
|
import { useRelationshipQuery } from '@utils/queryHooks/relationship'
|
2022-12-12 20:43:45 +01:00
|
|
|
import { getInstanceAccount, getInstanceUri } from '@utils/slices/instancesSlice'
|
2021-01-03 02:00:26 +01:00
|
|
|
import { StyleConstants } from '@utils/styles/constants'
|
|
|
|
import { useTheme } from '@utils/styles/ThemeManager'
|
2022-05-29 17:28:27 +02:00
|
|
|
import React from 'react'
|
2022-05-08 00:24:15 +02:00
|
|
|
import { useTranslation } from 'react-i18next'
|
2022-05-07 00:52:32 +02:00
|
|
|
import { View } from 'react-native'
|
2021-01-20 00:39:39 +01:00
|
|
|
import { useSelector } from 'react-redux'
|
2021-01-23 02:41:50 +01:00
|
|
|
import { PlaceholderLine } from 'rn-placeholder'
|
2020-12-27 16:25:29 +01:00
|
|
|
|
|
|
|
export interface Props {
|
|
|
|
account: Mastodon.Account | undefined
|
|
|
|
}
|
|
|
|
|
2022-12-12 20:43:45 +01:00
|
|
|
const AccountInformationAccount: React.FC<Props> = ({ account }) => {
|
2022-05-08 00:24:15 +02:00
|
|
|
const { t } = useTranslation('screenTabs')
|
2022-02-12 14:51:01 +01:00
|
|
|
const { colors } = useTheme()
|
2022-12-12 20:43:45 +01:00
|
|
|
const instanceAccount = useSelector(getInstanceAccount, (prev, next) => prev?.acct === next?.acct)
|
2021-02-20 19:12:44 +01:00
|
|
|
const instanceUri = useSelector(getInstanceUri)
|
2020-12-27 16:25:29 +01:00
|
|
|
|
2022-05-08 00:24:15 +02:00
|
|
|
const { data: relationship } = useRelationshipQuery({
|
2022-05-08 12:15:16 +02:00
|
|
|
id: account?.id || '',
|
2022-05-08 00:24:15 +02:00
|
|
|
options: { enabled: account !== undefined }
|
|
|
|
})
|
|
|
|
|
2022-12-12 20:43:45 +01:00
|
|
|
const localInstance = instanceAccount.acct.includes('@')
|
|
|
|
? instanceAccount.acct.includes(`@${instanceUri}`)
|
|
|
|
: true
|
|
|
|
|
2021-05-09 21:59:03 +02:00
|
|
|
if (account || (localInstance && instanceAccount)) {
|
2020-12-27 16:25:29 +01:00
|
|
|
return (
|
2021-01-23 02:41:50 +01:00
|
|
|
<View
|
2022-05-07 00:52:32 +02:00
|
|
|
style={{
|
|
|
|
flexDirection: 'row',
|
|
|
|
alignItems: 'center',
|
|
|
|
borderRadius: 0,
|
|
|
|
marginBottom: StyleConstants.Spacing.L
|
|
|
|
}}
|
2020-12-27 16:25:29 +01:00
|
|
|
>
|
2022-05-29 17:28:27 +02:00
|
|
|
<CustomText fontStyle='M' style={{ color: colors.secondary }}>
|
|
|
|
{account?.moved ? (
|
|
|
|
<>
|
|
|
|
{' '}
|
|
|
|
<CustomText selectable>@{account.moved.acct}</CustomText>
|
|
|
|
</>
|
|
|
|
) : null}
|
|
|
|
<CustomText
|
|
|
|
style={{
|
2022-12-12 20:43:45 +01:00
|
|
|
textDecorationLine: account?.moved || account?.suspended ? 'line-through' : undefined
|
2022-05-29 17:28:27 +02:00
|
|
|
}}
|
|
|
|
selectable
|
|
|
|
>
|
|
|
|
@{localInstance ? instanceAccount?.acct : account?.acct}
|
|
|
|
{localInstance ? `@${instanceUri}` : null}
|
2022-05-08 00:24:15 +02:00
|
|
|
</CustomText>
|
2022-05-29 17:28:27 +02:00
|
|
|
{relationship?.followed_by ? t('shared.account.followed_by') : null}
|
|
|
|
</CustomText>
|
2021-01-23 02:41:50 +01:00
|
|
|
{account?.locked ? (
|
|
|
|
<Icon
|
|
|
|
name='Lock'
|
2022-05-07 00:52:32 +02:00
|
|
|
style={{ marginLeft: StyleConstants.Spacing.S }}
|
2022-02-12 14:51:01 +01:00
|
|
|
color={colors.secondary}
|
2021-01-23 02:41:50 +01:00
|
|
|
size={StyleConstants.Font.Size.M}
|
|
|
|
/>
|
|
|
|
) : null}
|
|
|
|
{account?.bot ? (
|
|
|
|
<Icon
|
|
|
|
name='HardDrive'
|
2022-05-07 00:52:32 +02:00
|
|
|
style={{ marginLeft: StyleConstants.Spacing.S }}
|
2022-02-12 14:51:01 +01:00
|
|
|
color={colors.secondary}
|
2021-01-23 02:41:50 +01:00
|
|
|
size={StyleConstants.Font.Size.M}
|
|
|
|
/>
|
|
|
|
) : null}
|
|
|
|
</View>
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
return (
|
|
|
|
<PlaceholderLine
|
2021-04-24 15:03:17 +02:00
|
|
|
width={StyleConstants.Font.Size.M * 3}
|
2021-01-23 02:41:50 +01:00
|
|
|
height={StyleConstants.Font.LineHeight.M}
|
2022-02-12 14:51:01 +01:00
|
|
|
color={colors.shimmerDefault}
|
2021-01-23 02:41:50 +01:00
|
|
|
noMargin
|
2022-05-07 00:52:32 +02:00
|
|
|
style={{ borderRadius: 0, marginBottom: StyleConstants.Spacing.L }}
|
2021-01-23 02:41:50 +01:00
|
|
|
/>
|
2020-12-27 16:25:29 +01:00
|
|
|
)
|
|
|
|
}
|
2021-01-23 02:41:50 +01:00
|
|
|
}
|
2020-12-27 16:25:29 +01:00
|
|
|
|
2022-12-12 20:43:45 +01:00
|
|
|
export default AccountInformationAccount
|