mirror of
https://github.com/tooot-app/app
synced 2025-04-14 10:22:08 +02:00
parent
cc6740a7c0
commit
0b1fdf59ca
@ -2,6 +2,7 @@ import { createContext } from 'react'
|
|||||||
|
|
||||||
type AccountContextType = {
|
type AccountContextType = {
|
||||||
account?: Mastodon.Account
|
account?: Mastodon.Account
|
||||||
|
relationship?: Mastodon.Relationship
|
||||||
pageMe?: boolean
|
pageMe?: boolean
|
||||||
}
|
}
|
||||||
const AccountContext = createContext<AccountContextType>({} as AccountContextType)
|
const AccountContext = createContext<AccountContextType>({} as AccountContextType)
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { useRoute } from '@react-navigation/native'
|
|
||||||
import { StyleConstants } from '@utils/styles/constants'
|
import { StyleConstants } from '@utils/styles/constants'
|
||||||
import { useTheme } from '@utils/styles/ThemeManager'
|
import { useTheme } from '@utils/styles/ThemeManager'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
@ -11,16 +10,19 @@ import AccountInformationCreated from './Information/Created'
|
|||||||
import AccountInformationFields from './Information/Fields'
|
import AccountInformationFields from './Information/Fields'
|
||||||
import AccountInformationName from './Information/Name'
|
import AccountInformationName from './Information/Name'
|
||||||
import AccountInformationNote from './Information/Note'
|
import AccountInformationNote from './Information/Note'
|
||||||
|
import AccountInformationPrivateNote from './Information/PrivateNotes'
|
||||||
import AccountInformationStats from './Information/Stats'
|
import AccountInformationStats from './Information/Stats'
|
||||||
|
|
||||||
const AccountInformation: React.FC = () => {
|
const AccountInformation: React.FC = () => {
|
||||||
const { colors } = useTheme()
|
const { colors } = useTheme()
|
||||||
|
|
||||||
const { name } = useRoute()
|
|
||||||
const myInfo = name !== 'Tab-Shared-Account'
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.base}>
|
<View
|
||||||
|
style={{
|
||||||
|
marginTop: -StyleConstants.Avatar.L / 2,
|
||||||
|
padding: StyleConstants.Spacing.Global.PagePadding
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Placeholder
|
<Placeholder
|
||||||
Animation={props => (
|
Animation={props => (
|
||||||
<Fade {...props} style={{ backgroundColor: colors.shimmerHighlight }} />
|
<Fade {...props} style={{ backgroundColor: colors.shimmerHighlight }} />
|
||||||
@ -35,6 +37,8 @@ const AccountInformation: React.FC = () => {
|
|||||||
|
|
||||||
<AccountInformationAccount />
|
<AccountInformationAccount />
|
||||||
|
|
||||||
|
<AccountInformationPrivateNote />
|
||||||
|
|
||||||
<AccountInformationFields />
|
<AccountInformationFields />
|
||||||
|
|
||||||
<AccountInformationNote />
|
<AccountInformationNote />
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import Icon from '@components/Icon'
|
import Icon from '@components/Icon'
|
||||||
import CustomText from '@components/Text'
|
import CustomText from '@components/Text'
|
||||||
import { useRelationshipQuery } from '@utils/queryHooks/relationship'
|
|
||||||
import { getAccountStorage, useAccountStorage } from '@utils/storage/actions'
|
import { getAccountStorage, useAccountStorage } from '@utils/storage/actions'
|
||||||
import { StyleConstants } from '@utils/styles/constants'
|
import { StyleConstants } from '@utils/styles/constants'
|
||||||
import { useTheme } from '@utils/styles/ThemeManager'
|
import { useTheme } from '@utils/styles/ThemeManager'
|
||||||
@ -11,7 +10,7 @@ import { PlaceholderLine } from 'rn-placeholder'
|
|||||||
import AccountContext from '../Context'
|
import AccountContext from '../Context'
|
||||||
|
|
||||||
const AccountInformationAccount: React.FC = () => {
|
const AccountInformationAccount: React.FC = () => {
|
||||||
const { account, pageMe } = useContext(AccountContext)
|
const { account, relationship, pageMe } = useContext(AccountContext)
|
||||||
|
|
||||||
const { t } = useTranslation('screenTabs')
|
const { t } = useTranslation('screenTabs')
|
||||||
const { colors } = useTheme()
|
const { colors } = useTheme()
|
||||||
@ -19,8 +18,6 @@ const AccountInformationAccount: React.FC = () => {
|
|||||||
const [acct] = useAccountStorage.string('auth.account.acct')
|
const [acct] = useAccountStorage.string('auth.account.acct')
|
||||||
const domain = getAccountStorage.string('auth.account.domain')
|
const domain = getAccountStorage.string('auth.account.domain')
|
||||||
|
|
||||||
const { data: relationship } = useRelationshipQuery({ id: account?.id })
|
|
||||||
|
|
||||||
const localInstance = account?.acct.includes('@') ? account?.acct.includes(`@${domain}`) : true
|
const localInstance = account?.acct.includes('@') ? account?.acct.includes(`@${domain}`) : true
|
||||||
|
|
||||||
if (account || pageMe) {
|
if (account || pageMe) {
|
||||||
|
@ -2,7 +2,6 @@ import Button from '@components/Button'
|
|||||||
import menuAt from '@components/contextMenu/at'
|
import menuAt from '@components/contextMenu/at'
|
||||||
import { RelationshipOutgoing } from '@components/Relationship'
|
import { RelationshipOutgoing } from '@components/Relationship'
|
||||||
import { useNavigation } from '@react-navigation/native'
|
import { useNavigation } from '@react-navigation/native'
|
||||||
import { useRelationshipQuery } from '@utils/queryHooks/relationship'
|
|
||||||
import { useAccountStorage } from '@utils/storage/actions'
|
import { useAccountStorage } from '@utils/storage/actions'
|
||||||
import { StyleConstants } from '@utils/styles/constants'
|
import { StyleConstants } from '@utils/styles/constants'
|
||||||
import React, { useContext } from 'react'
|
import React, { useContext } from 'react'
|
||||||
@ -12,7 +11,7 @@ import * as DropdownMenu from 'zeego/dropdown-menu'
|
|||||||
import AccountContext from '../Context'
|
import AccountContext from '../Context'
|
||||||
|
|
||||||
const AccountInformationActions: React.FC = () => {
|
const AccountInformationActions: React.FC = () => {
|
||||||
const { account, pageMe } = useContext(AccountContext)
|
const { account, relationship, pageMe } = useContext(AccountContext)
|
||||||
|
|
||||||
if (!account || account.suspended) {
|
if (!account || account.suspended) {
|
||||||
return null
|
return null
|
||||||
@ -50,13 +49,12 @@ const AccountInformationActions: React.FC = () => {
|
|||||||
const [accountId] = useAccountStorage.string('auth.account.id')
|
const [accountId] = useAccountStorage.string('auth.account.id')
|
||||||
const ownAccount = account?.id === accountId
|
const ownAccount = account?.id === accountId
|
||||||
|
|
||||||
const query = useRelationshipQuery({ id: account.id })
|
|
||||||
const mAt = menuAt({ account })
|
const mAt = menuAt({ account })
|
||||||
|
|
||||||
if (!ownAccount && account) {
|
if (!ownAccount && account) {
|
||||||
return (
|
return (
|
||||||
<View style={styles.base}>
|
<View style={styles.base}>
|
||||||
{query.data && !query.data.blocked_by ? (
|
{relationship && !relationship.blocked_by ? (
|
||||||
<DropdownMenu.Root>
|
<DropdownMenu.Root>
|
||||||
<DropdownMenu.Trigger>
|
<DropdownMenu.Trigger>
|
||||||
<Button
|
<Button
|
||||||
|
28
src/screens/Tabs/Shared/Account/Information/PrivateNotes.tsx
Normal file
28
src/screens/Tabs/Shared/Account/Information/PrivateNotes.tsx
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import { ParseHTML } from '@components/Parse'
|
||||||
|
import { StyleConstants } from '@utils/styles/constants'
|
||||||
|
import { useTheme } from '@utils/styles/ThemeManager'
|
||||||
|
import React, { useContext } from 'react'
|
||||||
|
import { View } from 'react-native'
|
||||||
|
import AccountContext from '../Context'
|
||||||
|
|
||||||
|
const AccountInformationPrivateNote: React.FC = () => {
|
||||||
|
const { relationship, pageMe } = useContext(AccountContext)
|
||||||
|
if (pageMe) return null
|
||||||
|
|
||||||
|
const { colors } = useTheme()
|
||||||
|
|
||||||
|
return relationship?.note ? (
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
marginBottom: StyleConstants.Spacing.L,
|
||||||
|
borderLeftColor: colors.border,
|
||||||
|
borderLeftWidth: StyleConstants.Spacing.XS,
|
||||||
|
paddingLeft: StyleConstants.Spacing.S
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ParseHTML content={relationship.note} size={'S'} selectable numberOfLines={2} />
|
||||||
|
</View>
|
||||||
|
) : null
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AccountInformationPrivateNote
|
@ -7,6 +7,7 @@ import SegmentedControl from '@react-native-community/segmented-control'
|
|||||||
import { useQueryClient } from '@tanstack/react-query'
|
import { useQueryClient } from '@tanstack/react-query'
|
||||||
import { TabSharedStackScreenProps } from '@utils/navigation/navigators'
|
import { TabSharedStackScreenProps } from '@utils/navigation/navigators'
|
||||||
import { useAccountQuery } from '@utils/queryHooks/account'
|
import { useAccountQuery } from '@utils/queryHooks/account'
|
||||||
|
import { useRelationshipQuery } from '@utils/queryHooks/relationship'
|
||||||
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
||||||
import { StyleConstants } from '@utils/styles/constants'
|
import { StyleConstants } from '@utils/styles/constants'
|
||||||
import { useTheme } from '@utils/styles/ThemeManager'
|
import { useTheme } from '@utils/styles/ThemeManager'
|
||||||
@ -51,6 +52,10 @@ const TabSharedAccount: React.FC<TabSharedStackScreenProps<'Tab-Shared-Account'>
|
|||||||
onError: () => navigation.goBack()
|
onError: () => navigation.goBack()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
const { data: dataRelationship } = useRelationshipQuery({
|
||||||
|
id: account._remote ? data?.id : account.id,
|
||||||
|
options: { enabled: account._remote ? !!data?.id : true }
|
||||||
|
})
|
||||||
|
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const [queryKey, setQueryKey] = useState<QueryKeyTimeline>([
|
const [queryKey, setQueryKey] = useState<QueryKeyTimeline>([
|
||||||
@ -223,7 +228,7 @@ const TabSharedAccount: React.FC<TabSharedStackScreenProps<'Tab-Shared-Account'>
|
|||||||
}, [segment, dataUpdatedAt, mode])
|
}, [segment, dataUpdatedAt, mode])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AccountContext.Provider value={{ account: data }}>
|
<AccountContext.Provider value={{ account: data, relationship: dataRelationship }}>
|
||||||
<AccountNav scrollY={scrollY} />
|
<AccountNav scrollY={scrollY} />
|
||||||
|
|
||||||
{data?.suspended ? (
|
{data?.suspended ? (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user