mirror of https://github.com/tooot-app/app
Fixed #505
This commit is contained in:
parent
e1e700543f
commit
c79caa6dc7
|
@ -0,0 +1,50 @@
|
|||
import { useNavigation } from '@react-navigation/native'
|
||||
import { NativeStackNavigationProp } from '@react-navigation/native-stack'
|
||||
import { RootStackParamList } from '@utils/navigation/navigators'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
const menuAt = ({ account }: { account: Mastodon.Account }): ContextMenu[][] => {
|
||||
const { t } = useTranslation('componentContextMenu')
|
||||
const navigation = useNavigation<NativeStackNavigationProp<RootStackParamList>>()
|
||||
|
||||
const menus: ContextMenu[][] = []
|
||||
|
||||
menus.push([
|
||||
{
|
||||
key: 'at-direct',
|
||||
item: {
|
||||
onSelect: () =>
|
||||
navigation.navigate('Screen-Compose', {
|
||||
type: 'conversation',
|
||||
accts: [account.acct],
|
||||
visibility: 'direct'
|
||||
}),
|
||||
disabled: false,
|
||||
destructive: false,
|
||||
hidden: false
|
||||
},
|
||||
title: t('at.direct'),
|
||||
icon: 'envelope'
|
||||
},
|
||||
{
|
||||
key: 'at-public',
|
||||
item: {
|
||||
onSelect: () =>
|
||||
navigation.navigate('Screen-Compose', {
|
||||
type: 'conversation',
|
||||
accts: [account.acct],
|
||||
visibility: 'public'
|
||||
}),
|
||||
disabled: false,
|
||||
destructive: false,
|
||||
hidden: false
|
||||
},
|
||||
title: t('at.public'),
|
||||
icon: 'at'
|
||||
}
|
||||
])
|
||||
|
||||
return menus
|
||||
}
|
||||
|
||||
export default menuAt
|
|
@ -19,6 +19,10 @@
|
|||
"action": "Report and block user"
|
||||
}
|
||||
},
|
||||
"at": {
|
||||
"direct": "Direct message",
|
||||
"public": "Public message"
|
||||
},
|
||||
"copy": {
|
||||
"action": "Copy toot",
|
||||
"succeed": "Copied"
|
||||
|
|
|
@ -259,8 +259,10 @@ const ScreenCompose: React.FC<RootStackScreenProps<'Screen-Compose'>> = ({
|
|||
type='text'
|
||||
content={
|
||||
params?.type
|
||||
? params.type === 'conversation' && params.visibility === 'direct'
|
||||
? t(`heading.right.button.${params.type}`)
|
||||
: t('heading.right.button.default')
|
||||
: t('heading.right.button.default')
|
||||
}
|
||||
onPress={() => {
|
||||
composeDispatch({ type: 'posting', payload: true })
|
||||
|
|
|
@ -92,7 +92,7 @@ const composeParseState = (
|
|||
...composeInitialState,
|
||||
dirty: true,
|
||||
timestamp: Date.now(),
|
||||
...assignVisibility('direct')
|
||||
...assignVisibility(params.visibility || 'direct')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ const SettingsTooot: React.FC = () => {
|
|||
navigation.navigate('Screen-Compose', {
|
||||
type: 'conversation',
|
||||
accts: ['tooot@xmflsct.com'],
|
||||
visibility: 'direct',
|
||||
text:
|
||||
'[' +
|
||||
`${Platform.OS}/${Platform.Version}` +
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import Button from '@components/Button'
|
||||
import menuAt from '@components/contextMenu/at'
|
||||
import { RelationshipOutgoing } from '@components/Relationship'
|
||||
import { useNavigation } from '@react-navigation/native'
|
||||
import { useRelationshipQuery } from '@utils/queryHooks/relationship'
|
||||
|
@ -8,32 +9,13 @@ import React from 'react'
|
|||
import { useTranslation } from 'react-i18next'
|
||||
import { StyleSheet, View } from 'react-native'
|
||||
import { useSelector } from 'react-redux'
|
||||
import * as DropdownMenu from 'zeego/dropdown-menu'
|
||||
|
||||
export interface Props {
|
||||
account: Mastodon.Account | undefined
|
||||
myInfo?: boolean
|
||||
}
|
||||
|
||||
const Conversation = ({ account }: { account: Mastodon.Account }) => {
|
||||
const navigation = useNavigation<any>()
|
||||
const query = useRelationshipQuery({ id: account.id })
|
||||
|
||||
return query.data && !query.data.blocked_by ? (
|
||||
<Button
|
||||
round
|
||||
type='icon'
|
||||
content='Mail'
|
||||
style={styles.actionLeft}
|
||||
onPress={() =>
|
||||
navigation.navigate('Screen-Compose', {
|
||||
type: 'conversation',
|
||||
accts: [account.acct]
|
||||
})
|
||||
}
|
||||
/>
|
||||
) : null
|
||||
}
|
||||
|
||||
const AccountInformationActions: React.FC<Props> = ({ account, myInfo }) => {
|
||||
if (!account || account.suspended) {
|
||||
return null
|
||||
|
@ -71,10 +53,38 @@ const AccountInformationActions: React.FC<Props> = ({ account, myInfo }) => {
|
|||
const instanceAccount = useSelector(getInstanceAccount, () => true)
|
||||
const ownAccount = account?.id === instanceAccount?.id && account?.acct === instanceAccount?.acct
|
||||
|
||||
const query = useRelationshipQuery({ id: account.id })
|
||||
const mAt = menuAt({ account })
|
||||
|
||||
if (!ownAccount && account) {
|
||||
return (
|
||||
<View style={styles.base}>
|
||||
<Conversation account={account} />
|
||||
{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}
|
||||
<RelationshipOutgoing id={account.id} />
|
||||
</View>
|
||||
)
|
||||
|
@ -86,9 +96,9 @@ const AccountInformationActions: React.FC<Props> = ({ account, myInfo }) => {
|
|||
const styles = StyleSheet.create({
|
||||
base: {
|
||||
alignSelf: 'flex-end',
|
||||
flexDirection: 'row'
|
||||
},
|
||||
actionLeft: { marginRight: StyleConstants.Spacing.S }
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center'
|
||||
}
|
||||
})
|
||||
|
||||
export default AccountInformationActions
|
||||
|
|
|
@ -2,6 +2,7 @@ import { BottomTabScreenProps } from '@react-navigation/bottom-tabs'
|
|||
import { NavigatorScreenParams } from '@react-navigation/native'
|
||||
import { NativeStackScreenProps } from '@react-navigation/native-stack'
|
||||
import { StackNavigationProp } from '@react-navigation/stack'
|
||||
import { ComposeState } from '@screens/Compose/utils/types'
|
||||
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
||||
|
||||
export type RootStackParamList = {
|
||||
|
@ -38,6 +39,7 @@ export type RootStackParamList = {
|
|||
| {
|
||||
type: 'conversation'
|
||||
accts: Mastodon.Account['acct'][]
|
||||
visibility: ComposeState['visibility']
|
||||
text?: string // For contacting tooot only
|
||||
}
|
||||
| {
|
||||
|
|
Loading…
Reference in New Issue