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